Skip to content

Add PUT /users/:id endpoint - #99

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

Add PUT /users/:id endpoint#99
SeikoCode wants to merge 3 commits into
mate-academy:mainfrom
SeikoCode:feature/update-user-endpoint

Conversation

@SeikoCode

Copy link
Copy Markdown

Summary

  • Adds an updateUser(id, { name, email }) helper to db/store.js that looks up a user by id and updates its name/email in place, mirroring the existing getUserById/createUser conventions.
  • Adds a PUT /users/:id route in routes/users.js that validates the request body, returns 404 for unknown ids, and returns the updated user on success — following the same validation/response shape as the existing GET/POST /users handlers.

Why

tests/update-user.test.js (a grading test that must stay unedited) exercises a PUT /users/:id endpoint that didn't exist yet. This change implements it so the suite passes, without touching any other routes or the data-store's existing behavior.

Test plan

  • npm test — all 3 update-user.test.js cases pass (update existing user → 200 with updated fields; unknown id → 404; missing field → 400), plus the existing users.test.js suite still passes
  • npm run lint — no errors
  • Manually: POST /users to create a user, then PUT /users/:id with a full body to confirm the response reflects the update; try a bogus id and a body missing email to confirm 404/400 respectively

🤖 Generated with Claude Code

Mariia Zaitseva added 3 commits August 24, 2026 11:34
Enables looking up a user by id and updating its name/email, mirroring the existing getUserById/createUser conventions.
Validates name/email are present (400), returns 404 for unknown ids, and responds with the updated user on success — matching the existing GET/POST response conventions.
Documents the plan, model choice, commit split, and code-review results for the PUT /users/:id change.
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