Skip to content

Add PUT /users/:id endpoint - #27

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

Add PUT /users/:id endpoint#27
huuphong91 wants to merge 3 commits into
mate-academy:mainfrom
huuphong91:feat/update-user-endpoint

Conversation

@huuphong91

Copy link
Copy Markdown

Summary

  • Add PUT /users/:id to update an existing user's name and email
  • Add updateUser(id, { name, email }) to db/store.js, following the existing helper pattern
  • Validate name and email are present (400 on a missing field, matching the existing POST /users rule)
  • Return 404 when the id doesn't exist instead of crashing
  • Add NOTES.md covering the plan, model choice, commit split, and self-review

Test plan

  • npm test passes locally (9/9, including the provided tests/update-user.test.js and tests/notes.test.js)
  • PUT /users/:id with a valid body updates and returns the user (200)
  • PUT /users/:id for a nonexistent id returns 404
  • PUT /users/:id with a missing name or email returns 400

Your Name added 3 commits July 8, 2026 13:48
Follows the existing lookup/create pattern: returns null when the id
isn't found so callers can decide how to respond, instead of the store
throwing or guessing at HTTP semantics.
Validates name/email are present (400), looks up the user via the new
store helper and returns 404 if missing, otherwise responds with the
updated user — mirroring the existing GET/POST handlers' style.
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.

1 participant