Repository navigation
fix(endpoint-posts,endpoint-files): store a UUIDv7 uid and look posts up by it #964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
38ea4db
feat(indiekit): add a UUIDv7 backfill for posts without a uid
rmdes 2eaf2fb
feat(endpoint-micropub,endpoint-media): store a UUIDv7 uid on create
rmdes 4d10ad8
feat(indiekit): backfill missing uids before serving requests
rmdes 75597c1
refactor(endpoint-micropub,endpoint-media): return the stored uid
rmdes 1f39274
fix(endpoint-posts): look up posts by uid so older posts don't 404
rmdes 68821e8
fix(endpoint-micropub): keep uid when deleting a post
rmdes a027faf
fix(endpoint-micropub): don't let a client reassign a post's uid
rmdes 234dc6c
test(endpoint-posts): cover fetching a post outside the first page
rmdes 22a4b49
docs(endpoint-posts): correct getPostProperties return type
rmdes bcf4bf9
fix(indiekit): make the uid backfill resumable and concurrency-safe
rmdes e44502a
fix(indiekit): trace the uid backfill even when it's a no-op
rmdes db3d9de
fix(endpoint-files): look up files by uid so older files don't 404
rmdes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
packages/endpoint-media/test/integration/200-query-source-uid.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import { strict as assert } from "node:assert"; | ||
| import { after, before, describe, it } from "node:test"; | ||
|
|
||
| import { testDatabase } from "@indiekit-test/database"; | ||
| import { getFixture } from "@indiekit-test/fixtures"; | ||
| import { testServer } from "@indiekit-test/server"; | ||
| import { testToken } from "@indiekit-test/token"; | ||
| import supertest from "supertest"; | ||
|
|
||
| const { client, mongoServer, mongoUri } = await testDatabase(); | ||
| const server = await testServer({ | ||
| application: { mongodbUrl: mongoUri }, | ||
| }); | ||
| const request = supertest.agent(server); | ||
|
|
||
| describe("endpoint-media GET /media?q=source&uid=*", () => { | ||
| let seededUid; | ||
|
|
||
| before(async () => { | ||
| await request | ||
| .post("/media") | ||
| .auth(testToken(), { type: "bearer" }) | ||
| .set("accept", "application/json") | ||
| .attach("file", getFixture("file-types/photo.jpg", false), "photo.jpg"); | ||
|
|
||
| const result = await request | ||
| .get("/media") | ||
| .auth(testToken(), { type: "bearer" }) | ||
| .set("accept", "application/json") | ||
| .query({ q: "source" }); | ||
|
|
||
| seededUid = result.body.items[0].uid; | ||
| }); | ||
|
|
||
| it("Returns properties for a file by uid", async () => { | ||
| const result = await request | ||
| .get("/media") | ||
| .auth(testToken(), { type: "bearer" }) | ||
| .set("accept", "application/json") | ||
| .query({ q: "source" }) | ||
| .query({ uid: seededUid }); | ||
|
|
||
| assert.equal(result.status, 200); | ||
| assert.equal(result.body.uid, seededUid); | ||
| }); | ||
|
|
||
| after(async () => { | ||
| await client.close(); | ||
| await mongoServer.stop(); | ||
| server.close((error) => process.exit(error ? 1 : 0)); | ||
| }); | ||
| }); |
28 changes: 28 additions & 0 deletions
28
packages/endpoint-media/test/integration/404-query-source-uid-not-found.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { strict as assert } from "node:assert"; | ||
| import { after, describe, it } from "node:test"; | ||
|
|
||
| import { testServer } from "@indiekit-test/server"; | ||
| import { testToken } from "@indiekit-test/token"; | ||
| import supertest from "supertest"; | ||
|
|
||
| const server = await testServer(); | ||
| const request = supertest.agent(server); | ||
|
|
||
| describe("endpoint-media GET /media?q=source&uid=*", () => { | ||
| it("Returns 404 error uid not found", async () => { | ||
| const result = await request | ||
| .get("/media") | ||
| .auth(testToken(), { type: "bearer" }) | ||
| .set("accept", "application/json") | ||
| .query({ q: "source" }) | ||
| .query({ uid: "unknown-uid" }); | ||
|
|
||
| assert.equal(result.status, 404); | ||
| assert.equal( | ||
| result.body.error_description, | ||
| "No database record found for file", | ||
| ); | ||
| }); | ||
|
|
||
| after(() => server.close()); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.