Skip to content

Add update user endpoint v2 - #113

Closed
sinkobela wants to merge 9 commits into
mate-academy:mainfrom
sinkobela:add-update-user-endpoint-v2
Closed

Add update user endpoint v2#113
sinkobela wants to merge 9 commits into
mate-academy:mainfrom
sinkobela:add-update-user-endpoint-v2

Conversation

@sinkobela

Copy link
Copy Markdown

No description provided.

Adds an updateUser(id, { name, email }) function to the in-memory
store, following the existing getUserById/createUser pattern. Returns
undefined when the id doesn't match any user, so callers can decide
how to respond (used for the 404 case in the update endpoint).
Adds an update-user route: validates that name and email are present
(400 otherwise), looks up the user via the store, and returns 404 if
it doesn't exist. Returns the updated user with 200 on success.

Validation mirrors the existing POST /users pattern for consistency.
Explains the approved plan, model choice, why the commits are split
the way they are, and what self-review confirmed before opening the
PR.
Add update-user endpoint (PUT /users/:id)
Adds an updateUser(id, { name, email }) function to the in-memory
store, following the existing getUserById/createUser pattern. Returns
undefined when the id doesn't match any user, so callers can decide
how to respond (used for the 404 case in the update endpoint).
Adds an update-user route: validates that name and email are present
(400 otherwise), looks up the user via the store, and returns 404 if
it doesn't exist. Returns the updated user with 200 on success.

Validation mirrors the existing POST /users pattern for consistency.
Explains the approved plan, model choice, why the commits are split
the way they are, and what self-review confirmed before opening the
PR.
Empty commit to trigger the CI workflow now that GitHub Actions has
been enabled on this fork (it was disabled by default and never ran
on any prior push or PR).

@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

All three files implement the required functionality correctly. The PUT /users/:id endpoint in routes/users.js validates name and email presence (400), checks user existence via db/store.js (404), and returns the updated user on success (200). The updateUser helper in db/store.js correctly returns undefined for non-existent ids, following the existing store pattern. The validation-before-existence-check ordering is correct and intentional. No critical issues were found — the implementation is complete and meets all stated requirements.


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

@sinkobela sinkobela closed this by deleting the head repository Aug 28, 2026
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