Add update user endpoint - #136
Conversation
Adds a store-level function that finds a user by id, updates their name/email in place, and returns undefined when the id doesn't exist — mirroring getUserById's existing not-found contract so route handlers can decide the HTTP status. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015wXBFi7ha4kiisnUrNjAtJ
Validates that name and email are present (400 if not, matching POST's error message), then updates the user via the store, returning 404 if the id doesn't exist rather than crashing. Follows the existing GET/:id and POST response conventions for consistency. Turns the update-user.test.js suite green. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015wXBFi7ha4kiisnUrNjAtJ
Documents the plan I approved, model choice, why the change is split into two commits, and what code review checked before pushing. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015wXBFi7ha4kiisnUrNjAtJ
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am approving this change. The PUT /users/:id route correctly validates required fields (returning 400 on missing data), returns 404 for unknown IDs, and responds with the updated user on success. The updateUser helper in db/store.js follows the established pattern and cleanly returns undefined when the user isn’t found. NOTES.md clearly documents the plan, approach, and review findings, meeting the documentation requirement. While I couldn’t verify CI/test run status here, the implemented behavior matches the expected tests. As a minor improvement (optional), consider stricter validation (e.g., reject empty strings) if desired. Nicely done implementing the feature in a focused and consistent way.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
This PR adds an endpoint to update users. The changes are the following:
Added the function to store.js
Configured the new endpoint in the users.js file
Created the NOTES.MD to explain all the changes.