Skip to content

Add PUT /users/:id (update a user) endpoint - #139

Open
winch77 wants to merge 3 commits into
mate-academy:mainfrom
winch77:feature/update-user-endpoint
Open

Add PUT /users/:id (update a user) endpoint#139
winch77 wants to merge 3 commits into
mate-academy:mainfrom
winch77:feature/update-user-endpoint

Conversation

@winch77

@winch77 winch77 commented Sep 7, 2026

Copy link
Copy Markdown

Summary

  • Add updateUser(id, { name, email }) to db/store.js, following the existing no-throw convention (returns undefined when the id isn't found)
  • Add PUT /users/:id in routes/users.js, validating name/email (400 if missing) and returning 404 for an unknown id, matching the error shapes already used by POST / and GET /:id

Test plan

  • npm test — all 3 cases in tests/update-user.test.js pass (200 update, 404 unknown id, 400 missing field)
  • Existing tests/users.test.js suite still passes (no regressions)

🤖 Generated with Claude Code

https://claude.ai/code/session_01UHXKDVE433kqpoHV89373e

winch77 and others added 2 commits September 7, 2026 21:43
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 mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

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 mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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! ✨

Footnotes

  1. Rate AI review example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants