Skip to content

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

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

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

Conversation

@yanavedel

Copy link
Copy Markdown

Summary

  • Adds PUT /users/:id to update an existing user's name/email
  • Validates the body (400 if name or email is missing), matching the existing POST / handler
  • Returns 404 for an unknown id, matching the existing GET /:id handler
  • Adds store.updateUser(id, { name, email }) in db/store.js, following the existing getUserById/createUser pattern — no direct array access from the route
  • NOTES.md covers the plan, model choice, commit split, and what the self-review checked

Test plan

  • npm test — all cases in tests/update-user.test.js pass (200 + updated fields, 404 for unknown id, 400 for a missing field), no regressions in the rest of the suite
  • Reviewer: try PUT /users/1 with a full body (200, fields updated), PUT /users/9999 with a full body (404), and PUT /users/1 with only name (400)

yana_we4sea added 3 commits September 5, 2026 22:21
Follows the existing getUserById/createUser pattern: looks the user up
by id, returns null if it's not found, otherwise mutates and returns it.
Validates name/email are present (400, same message as POST /) before
checking the id exists (404 via store.updateUser), then returns the
updated user. Turns tests/update-user.test.js green.

@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 fully satisfies all task requirements. The PUT /users/:id endpoint correctly validates input (returning 400 for missing name/email fields), returns 404 for unknown user ids, and properly routes data access through db/store.js following the existing patterns. The updateUser function in the store correctly handles the mutation and not-found cases. The NOTES.md contains substantive documentation covering the plan approval process, model choice rationale, commit strategy, and self-review findings. All tests pass and no issues were identified across the three modified files. Great work implementing this feature with proper validation ordering and following the existing codebase patterns.


✨ 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