-
Notifications
You must be signed in to change notification settings - Fork 4
@id and id negotiation #191
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
40 commits
Select commit
Hold shift + click to select a range
47463f8
Good id negotiation in the db controller for a create request/response
thehabes 087a02b
touch em all
thehabes 338c60b
touch em all
thehabes cae97bc
touch em all
thehabes bb594fc
Get rid of _id regularly
thehabes 064739c
Since it is somewhat likely @context will be an array
thehabes 4442fe3
tests
thehabes 1b8e894
Tests we will need TODO
thehabes 9803a64
Good error throughput
thehabes 4e0afaa
Changes from manual testing
thehabes ae76332
Error redo
thehabes 6d0817f
Error redo
thehabes a1154c6
Error redo
thehabes 9a62eb8
Now errors are handled in rest.js without unnecessary interceptions
thehabes 2d0626d
documentation and cleanup
thehabes 6509348
documentation and cleanup
thehabes 8038cab
documentation and cleanup
thehabes 1f7e3f4
can put this back now
thehabes f84e09c
can put this back now
thehabes 1e65081
can put this back now
thehabes af5aa17
65 bulk update (#192)
thehabes 46cc3e2
ew the nasties
thehabes 6181f85
Register the bulkUpdate route. Make the errors behave.
thehabes c046b05
Functional bulkUpdate and much improved error reporting.
thehabes bbb88c5
bulkUpdate test entries. skipping end to end test for it, for now.
thehabes e88c769
Harder checks against objects supplied in the bodies of bulk endpoints.
thehabes 86a43b8
Harder checks against objects supplied in the bodies of bulk endpoints.
thehabes b7f0b9f
ah ')'
thehabes 65bed62
overachieving just a lil bit
thehabes 1f3bbe1
Performance update for bulkCreate and bulkUpdate, which may not proce…
thehabes 20fd5d4
Bump @babel/helpers from 7.23.5 to 7.27.0 (#193)
dependabot[bot] ebe2101
no prezi 2
thehabes e51c374
yes oa
thehabes eeead0f
cmon
thehabes 22c121f
lint this bad indent
thehabes efe2e2d
formally skip() this test
thehabes 25a070b
API wording around /bulkUpdate and /bulkCreate.
thehabes 298d8cc
oh boy missed this
thehabes bb5a31f
oh boy missed this
thehabes 331a656
oh boy missed this
thehabes 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { jest } from "@jest/globals" | ||
|
|
||
| // Only real way to test an express route is to mount it and call it so that we can use the req, res, next. | ||
| import express from "express" | ||
| import request from "supertest" | ||
| import controller from '../../db-controller.js' | ||
|
|
||
| // Here is the auth mock so we get a req.user and the controller can function without a NPE. | ||
| const addAuth = (req, res, next) => { | ||
| req.user = {"http://store.rerum.io/agent": "https://store.rerum.io/v1/id/agent007"} | ||
| next() | ||
| } | ||
|
|
||
| const routeTester = new express() | ||
| routeTester.use(express.json()) | ||
| routeTester.use(express.urlencoded({ extended: false })) | ||
|
|
||
| // Mount our own /bulkCreate route without auth that will use controller.bulkCreate | ||
| routeTester.use("/bulkUpdate", [addAuth, controller.bulkUpdate]) | ||
|
|
||
| it.skip("'/bulkUpdate' route functions", async () => { | ||
| // TODO without hitting the v1/id/11111 object because it is already abused. | ||
| }) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { jest } from "@jest/globals" | ||
| import dotenv from "dotenv" | ||
| import controller from '../../db-controller.js' | ||
|
|
||
| it("Functional '@id-id' negotiation on objects returned.", async () => { | ||
| let negotiate = { | ||
| "@context": "http://iiif.io/api/presentation/3/context.json", | ||
| "_id": "example", | ||
| "@id": `${process.env.RERUM_ID_PREFIX}example`, | ||
| "test": "item" | ||
| } | ||
| negotiate = controller.idNegotiation(negotiate) | ||
| expect(negotiate._id).toBeUndefined() | ||
| expect(negotiate["@id"]).toBeUndefined() | ||
| expect(negotiate.id).toBe(`${process.env.RERUM_ID_PREFIX}example`) | ||
| expect(negotiate.test).toBe("item") | ||
|
|
||
| let nonegotiate = { | ||
| "@context":"http://example.org/context.json", | ||
| "_id": "example", | ||
| "@id": `${process.env.RERUM_ID_PREFIX}example`, | ||
| "id": "test_example", | ||
| "test":"item" | ||
| } | ||
| nonegotiate = controller.idNegotiation(nonegotiate) | ||
| expect(nonegotiate._id).toBeUndefined() | ||
| expect(nonegotiate["@id"]).toBe(`${process.env.RERUM_ID_PREFIX}example`) | ||
| expect(nonegotiate.id).toBe("test_example") | ||
| expect(nonegotiate.test).toBe("item") | ||
| }) |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/usr/bin/env node | ||
| import express from 'express' | ||
| const router = express.Router() | ||
|
|
||
| //This controller will handle all MongoDB interactions. | ||
| import controller from '../db-controller.js' | ||
| import auth from '../auth/index.js' | ||
|
|
||
| router.route('/') | ||
| .put(auth.checkJwt, controller.bulkUpdate) | ||
| .all((req, res, next) => { | ||
| res.statusMessage = 'Improper request method for creating, please use PUT.' | ||
| res.status(405) | ||
| next(res) | ||
| }) | ||
|
|
||
| export default router |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, this is true in spirit