Skip to content

Add PUT /users/:id update-user endpoint - #94

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

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

Conversation

@FelipeDeYcaza

Copy link
Copy Markdown

Summary

  • Add updateUser(id, { name, email }) to db/store.js, following the existing getUserById/createUser pattern
  • Add PUT /users/:id to routes/users.js: validates name/email are present (400), 404s for an unknown id, otherwise updates and returns the user (200)
  • Add NOTES.md with the plan, model choice, commit split, and review notes

Why

Ships the "update a user" feature described in the course README — the endpoint the pre-written tests/update-user.test.js grades against.

Test plan

  • npm test — all 9 tests pass, including the three update-user.test.js cases (200 update, 404 unknown id, 400 missing field) and the NOTES.md checks
  • npm run lint — clean
  • Reviewer: manually try PUT /users/1 with a full body (200), PUT /users/9999 with a full body (404), and PUT /users/1 with only name (400)

Follows the existing getUserById/createUser pattern: looks the user
up by id, returns null if missing so the route layer can 404, or
mutates and returns the record in place.
Validates name/email are present (400 if not), 404s when the id
doesn't match a user, otherwise updates and returns the record.
Mirrors the existing GET /:id and POST / handlers.
Write-up of the plan, model choice, commit split, and what the
self-review found for the update-user endpoint.
@FelipeDeYcaza

Copy link
Copy Markdown
Author

Opened against the wrong repo by mistake — closing and resubmitting against my own fork.

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