Add PUT /users/:id (update a user) - #122
Open
emcconde2 wants to merge 4 commits into
Open
Conversation
Mirrors createUser/getUserById: finds a user by id and updates their name/email in place, returning undefined if the id doesn't exist.
Validates name/email like POST does, then updates via the store helper; returns 404 when the id doesn't exist.
Self-review flagged the duplicated find() lookup; updateUser now calls the existing helper instead of re-implementing it.
Documents the plan, model choice, commit split, and what self-review caught for the update-user endpoint.
mateacademy-ai-mentor
approved these changes
Sep 1, 2026
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your implementation is approved. The db/store.js correctly implements the updateUser helper with proper user lookup via getUserById, undefined return for missing users, and in-place mutation. The routes/users.js endpoint properly handles PUT requests with id-parsing, input validation (400 for missing fields), 404 for unknown ids, and 200 responses with the updated user. The NOTES.md documents your plan, model choice, commit strategy, and self-review findings with appropriate specifics. All three files have been reviewed and meet the task requirements.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
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
updateUser(id, { name, email })todb/store.js, following the existingcreateUser/getUserByIdpattern.PUT /users/:idtoroutes/users.js: validatesname/email(400 if missing), returns 404 for an unknown id, 200 with the updated user otherwise.NOTES.mddocumenting the plan, model choice, commit split, and self-review findings.Why
Implements the "update a user" endpoint required by the course project, going through the existing
db/store.jsdata-access pattern rather than touching data directly in the route.Test plan
npm testis green (9/9), including the pre-writtentests/update-user.test.jsPUT /users/:idwith a valid body updates the user and returns 200PUT /users/9999(unknown id) returns 404PUT /users/:idwith a missing field returns 400NOTES.mdpresent with real content