Add PUT /users/:id (update a user) endpoint - #139
Conversation
Finds a user by id and updates their name/email in place, returning undefined when no match is found so callers can decide how to respond (mirrors getUserById's no-throw convention). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UHXKDVE433kqpoHV89373e
Validates that name and email are present (400 otherwise) and returns 404 for an unknown id, matching the error shapes already used by the existing POST / and GET /:id handlers. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UHXKDVE433kqpoHV89373e
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
The core implementation is excellent and all 7 API tests pass successfully. The PUT /users/:id endpoint in routes/users.js correctly validates input (returning 400 for missing fields), handles unknown users (returning 404), and updates user data through the updateUser function in db/store.js. However, the NOTES.md file is missing from the submission. This is a mandatory course requirement checked by tests/notes.test.js - the test suite explicitly verifies both that the file exists and contains real content documenting your plan, model choice, commit split, and review notes. Without this file, the automated grading checks will fail. Please create and commit a NOTES.md at the project root with the required documentation sections.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
Covers plan, model choice, commit split, and review findings, as required by the notes.test.js grading check. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UHXKDVE433kqpoHV89373e
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your implementation is complete and correct. The PUT /users/:id endpoint properly validates input (returning 400 for missing fields), handles unknown users (returning 404), and delegates data access through db/store.js using the updateUser function. All three test cases pass, no regressions exist, and your NOTES.md documents the plan, model choice, commit strategy, and review findings with substantive content. No changes needed.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Summary
updateUser(id, { name, email })todb/store.js, following the existing no-throw convention (returnsundefinedwhen the id isn't found)PUT /users/:idinroutes/users.js, validatingname/email(400 if missing) and returning 404 for an unknown id, matching the error shapes already used byPOST /andGET /:idTest plan
npm test— all 3 cases intests/update-user.test.jspass (200 update, 404 unknown id, 400 missing field)tests/users.test.jssuite still passes (no regressions)🤖 Generated with Claude Code
https://claude.ai/code/session_01UHXKDVE433kqpoHV89373e