-
Notifications
You must be signed in to change notification settings - Fork 171
Add PUT /users/:id endpoint to update a user #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
GHolden660
wants to merge
5
commits into
mate-academy:main
Choose a base branch
from
GHolden660:update-user-details
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c3c5682
Add updateUser helper to the in-memory store
GHolden660 95ecac6
Add PUT /users/:id endpoint to update a user
GHolden660 f71d5c0
Add NOTES.md explaining the update-user change
GHolden660 9061003
add whitespace
GHolden660 ed64207
Update NOTES.md to mention the whitespace commit
GHolden660 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| Note: `routes/users.js` is included in the committed changes. | ||
|
|
||
| - What was in the plan you approved, and did you edit anything before approving? | ||
|
GHolden660 marked this conversation as resolved.
|
||
|
|
||
| The plan was to add an `updateUser` helper to `db/store.js` that finds a user by id and returns null if it doesn't exist, then add a `PUT /users/:id` route in `routes/users.js` that validates `name` and `email` are present (400 if not), looks up the user via the store (404 if missing), and otherwise updates and returns it. I didn't need to edit anything — it matched the existing GET/POST patterns closely enough to approve as-is. | ||
|
|
||
| - Which model did you choose, and why? | ||
| I chose Sonnet as my model, as we are making changes where there is a clear pattern of code to follow from. | ||
|
|
||
| - How did you split your commits, and why that way? | ||
| One commit for the `db/store.js` change (the `updateUser` helper) and a second for the `routes/users.js` route, since they're separate layers of the same feature and each is reviewable on its own. NOTES.md is its own commit, and a small follow-up commit added intentional whitespace to `routes/users.js`. | ||
|
|
||
| - What did your review catch — or confirm was already fine? | ||
| Review confirmed validation runs before the not-found check (matching the existing POST behavior) and that the not-found response returns a clean 404 instead of throwing. No changes were needed. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
routes/users.jsfile with thePUT /users/:idroute handler is missing. This file must include: (1) the PUT route at/users/:id, (2) 400 response whennameoremailis missing from request body, (3) 404 response when user id doesn't exist, and (4) a call toupdateUserfromdb/store.jsto update and return the user on success.