Feat/update user endpoint - #23
Open
nemsys54 wants to merge 3 commits into
Open
Conversation
Run npm install to pull in express, supertest, and eslint from the existing package-lock.json. No source changes — lockfile only. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements the update-a-user feature:
- db/store.js: add updateUser(id, { name, email }) — finds the user by
numeric id, mutates name/email in place, returns the updated user or
undefined on a miss (same absence-signal pattern as getUserById).
- routes/users.js: add PUT /:id handler — validates body first (400 if
name or email is missing), then looks up via updateUser (404 if
undefined), otherwise responds 200 with the updated user. Validation
runs before lookup so a missing field always returns 400, even for an
id that exists.
All three cases in tests/update-user.test.js now pass:
update existing user → 200
unknown id → 404
missing field → 400
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Course deliverable covering: the change plan (store helper + route handler, validate-first ordering derived from reading the tests), model choice (opusplan — Opus for planning, Sonnet for implementation), commit split rationale, and self-review findings (no bugs caught; validate-before-lookup ordering confirmed correct). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.