Add PUT /users/:id (update-user endpoint) - #135
Conversation
Follows the existing getUserById/createUser pattern: looks the user up by id, returns null if it's not found, otherwise mutates and returns it.
Validates name/email are present (400, same message as POST /) before checking the id exists (404 via store.updateUser), then returns the updated user. Turns tests/update-user.test.js green.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your implementation fully satisfies all task requirements. The PUT /users/:id endpoint correctly validates input (returning 400 for missing name/email fields), returns 404 for unknown user ids, and properly routes data access through db/store.js following the existing patterns. The updateUser function in the store correctly handles the mutation and not-found cases. The NOTES.md contains substantive documentation covering the plan approval process, model choice rationale, commit strategy, and self-review findings. All tests pass and no issues were identified across the three modified files. Great work implementing this feature with proper validation ordering and following the existing codebase patterns.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Summary
PUT /users/:idto update an existing user'sname/emailnameoremailis missing), matching the existingPOST /handlerGET /:idhandlerstore.updateUser(id, { name, email })indb/store.js, following the existinggetUserById/createUserpattern — no direct array access from the routeNOTES.mdcovers the plan, model choice, commit split, and what the self-review checkedTest plan
npm test— all cases intests/update-user.test.jspass (200 + updated fields, 404 for unknown id, 400 for a missing field), no regressions in the rest of the suitePUT /users/1with a full body (200, fields updated),PUT /users/9999with a full body (404), andPUT /users/1with onlyname(400)