Skip to content

Add update user endpoint - #136

Open
nomasgabo wants to merge 3 commits into
mate-academy:mainfrom
nomasgabo:add-update-user-endpoint
Open

Add update user endpoint#136
nomasgabo wants to merge 3 commits into
mate-academy:mainfrom
nomasgabo:add-update-user-endpoint

Conversation

@nomasgabo

Copy link
Copy Markdown

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.

nomasgabo and others added 3 commits September 6, 2026 01:36
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 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

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! ✨

Footnotes

  1. Rate AI review example

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