Skip to content

Add PUT /users/:id endpoint to update users - #24

Open
barnzdan wants to merge 3 commits into
mate-academy:mainfrom
barnzdan:add-update-user-endpoint
Open

Add PUT /users/:id endpoint to update users#24
barnzdan wants to merge 3 commits into
mate-academy:mainfrom
barnzdan:add-update-user-endpoint

Conversation

@barnzdan

@barnzdan barnzdan commented Jul 7, 2026

Copy link
Copy Markdown

Summary

Added a PUT /users/:id endpoint to the users resource that updates an existing user by id. The change includes an updateUser helper function in the store layer and full input validation with proper error responses.

What changed

  • db/store.js: Added updateUser(id, { name, email }) function that updates a user in place and returns the updated user or undefined if not found.
  • routes/users.js: Added PUT /:id handler that validates required fields (name and email), calls the store function, and returns appropriate status codes (200 on success, 400 on validation failure, 404 if user not found).
  • NOTES.md: Added implementation notes documenting the plan, model choice, commit strategy, and review findings.

Testing

  • All grading tests pass: update existing user (200), update non-existent user (404), missing required field (400).
  • All existing tests remain green: health check, list users, get user by id, create user.
  • Linter is clean.

Test cases to verify

  • Success case: PUT /users/1 with {"name": "Updated", "email": "updated@example.com"} should return 200 with updated fields.
  • Not found: PUT /users/9999 with valid data should return 404.
  • Invalid input: PUT /users/1 with {"name": "Only Name"} (missing email) should return 400.

Dan Barnes and others added 3 commits July 7, 2026 09:14
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
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