Add PUT /users/:id endpoint to update users - #24
Open
barnzdan wants to merge 3 commits into
Open
Conversation
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
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
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.
Summary
Added a
PUT /users/:idendpoint to the users resource that updates an existing user by id. The change includes anupdateUserhelper function in the store layer and full input validation with proper error responses.What changed
updateUser(id, { name, email })function that updates a user in place and returns the updated user or undefined if not found.PUT /:idhandler that validates required fields (name and email), calls the store function, and returns appropriate status codes (200 on success, 400 on validation failure, 404 if user not found).Testing
Test cases to verify
PUT /users/1with{"name": "Updated", "email": "updated@example.com"}should return 200 with updated fields.PUT /users/9999with valid data should return 404.PUT /users/1with{"name": "Only Name"}(missing email) should return 400.