-
Notifications
You must be signed in to change notification settings - Fork 27
publish 0.2.0 #41
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
publish 0.2.0 #41
Conversation
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
# Background My overall goal was to change from a: `POST /collections/<collectionId>/items/<itemId>/edit` to `PATCH /collections/<collectionId>/items/<itemId>` Which was more RESTful and also conforms to the stac-api's Transaction specification: https://github.com/radiantearth/stac-api-spec/tree/master/extensions/transaction An /edit path is more traditionally used to render a HTML form which eventually will post to a PUT/PATCH endpoint. # What's Includes I also adjusted aspects of areas I was touching directly: - The above route change - Ability to easily toggle whether Transaction extension endpoints are available - Simple HTTP constant utils introduced - Fixed a bug where we required a blank `properties` param even if not are being modified # Explanation of changes We have a DIY routing approach inside api.js. Previously it was working with paths only, so I added support for also recognizing the HTTP method when it comes to determining different behavior for identical paths. I found myself working in several cases with inline string literals for HTTP methods. I'd rather use constants and symbols, so I made a really minimal util to provide this. I introduced a way to easily toggle the transaction endpoints, driven by an environment variable. I also instructions to the README regarding this. Finally, I fixed an issue that required callers to specify a blank `properties` param even if none are being modified. The problem before was the edit endpoint trying to set an `updatedAt` date inside this object, and if it was nil there'd be an exception. # Testing The new behavior is triggered during a call to: `PATCH /collections/<collectionId>/items/<itemId>` Which is primarily used to change the collection of an item. Sample bodies include: ``` { "collection": "new-collection" } ``` or with other properties ``` { "collection": "new-collection", "properties": { "some-other-property": true } } ``` - `properties` will always get an `updated` attribute automatically assigned to the current date. - If other attributes are alongside in this object, it's merged with them. - If the input tries to provide updated as one of those attributes, ours is overwritten. - If no properties object is provided, we default to one with only `updated` ----- It's probably also worth testing other http methods on this same route, such as: `GET /collections/<collectionId>/items/<itemId>` # Toggling the Transactions extensions See the note in README, but essentially this is driven by a boolean ENV setting in serverless.yml. Previously we relied on commenting code, and moreover a code commit to change it.
Improve partial item editing / enabling of Transactions extensions
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.