Skip to content

Add PUT /users/:id endpoint to update a user - #129

Open
yuliyarudzko wants to merge 4 commits into
mate-academy:mainfrom
yuliyarudzko:add-update-user-endpoint
Open

Add PUT /users/:id endpoint to update a user#129
yuliyarudzko wants to merge 4 commits into
mate-academy:mainfrom
yuliyarudzko:add-update-user-endpoint

Conversation

@yuliyarudzko

@yuliyarudzko yuliyarudzko commented Sep 4, 2026

Copy link
Copy Markdown

Summary

  • Add updateUser(id, { name, email }) to db/store.js, mirroring the existing createUser/getUserById style: finds a user by id and updates it in place, returning null if not found.
  • Add PUT /users/:id to routes/users.js: validates that both name and email are present (400 if not), then updates via the store, returning 404 when the id doesn't exist.

Why

Adds the "update a user" capability to the users resource, following the same validate-then-lookup pattern already used by GET /users/:id and POST /users.

Test plan

  • npm test — all 9 tests pass, including the three tests/update-user.test.js cases (200 update, 404 not-found, 400 missing field)
  • npm run lint — no issues
  • Manual check: PUT /users/1 with a full body → 200 with updated fields; PUT /users/9999 → 404; PUT /users/1 with only name → 400

🤖 Generated with Claude Code

https://claude.ai/code/session_01BZKasjkVMDbaS9zPBFz41Z

rudzkoy and others added 3 commits September 4, 2026 10:57
Mirrors createUser/getUserById: finds a user by id and updates its
name/email in place, returning null when the id doesn't exist so
callers can return a 404.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BZKasjkVMDbaS9zPBFz41Z
Validates that name and email are both present (400 if not), then
updates via the store, returning 404 when the id doesn't exist.
Follows the same validate-then-lookup order as the existing routes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BZKasjkVMDbaS9zPBFz41Z
Covers the approved plan, model choice, commit split, and what the
code review caught.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BZKasjkVMDbaS9zPBFz41Z

@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

Your implementation is functionally complete and correct — all 7 API tests pass, including the PUT /users/:id endpoint with validation and 404 handling. However, you're missing a required NOTES.md file at the project root, which is part of the task definition of done. The tests NOTES.md exists at the project root and NOTES.md has real content are failing. Please create this file containing your plan, model choice, commit split organization, and any review findings or notes about the implementation.


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

Important

Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.

Tip

If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.

Caution

Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.

Footnotes

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

@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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

The prior AI review flagged NOTES.md as missing while attributing the
finding to commit b1885d5, which is the commit that added it. This
empty commit exists only to give the reviewer a new HEAD to re-check.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BZKasjkVMDbaS9zPBFz41Z

@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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

@yuliyarudzko

Copy link
Copy Markdown
Author

NOTES.md is present. Check yuliyarudzko@b1885d5

@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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

@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.

Sorry, the pull request review was unsuccessful for the following reasons:

Warning

No changes were made in the pull request since the last review. Please make sure that you have added files to the pull request and committed the changes.
[CODE: NCM]

If the issue is within your control, please address it.
The next review attempt will automatically launch in about 1 hour.
If you believe this is an error or need assistance, please contact the support team.

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.

3 participants