Add PUT /users/:id endpoint - #99
Open
SeikoCode wants to merge 3 commits into
Open
Conversation
added 3 commits
August 24, 2026 11:34
Enables looking up a user by id and updating its name/email, mirroring the existing getUserById/createUser conventions.
Validates name/email are present (400), returns 404 for unknown ids, and responds with the updated user on success — matching the existing GET/POST response conventions.
Documents the plan, model choice, commit split, and code-review results for the PUT /users/:id change.
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 })helper todb/store.jsthat looks up a user by id and updates itsname/emailin place, mirroring the existinggetUserById/createUserconventions.PUT /users/:idroute inroutes/users.jsthat validates the request body, returns 404 for unknown ids, and returns the updated user on success — following the same validation/response shape as the existingGET/POST /usershandlers.Why
tests/update-user.test.js(a grading test that must stay unedited) exercises aPUT /users/:idendpoint that didn't exist yet. This change implements it so the suite passes, without touching any other routes or the data-store's existing behavior.Test plan
npm test— all 3update-user.test.jscases pass (update existing user → 200 with updated fields; unknown id → 404; missing field → 400), plus the existingusers.test.jssuite still passesnpm run lint— no errorsPOST /usersto create a user, thenPUT /users/:idwith a full body to confirm the response reflects the update; try a bogus id and a body missingemailto confirm 404/400 respectively🤖 Generated with Claude Code