Skip to content

Feat/update user endpoint - #23

Open
nemsys54 wants to merge 3 commits into
mate-academy:mainfrom
nemsys54:feat/update-user-endpoint
Open

Feat/update user endpoint#23
nemsys54 wants to merge 3 commits into
mate-academy:mainfrom
nemsys54:feat/update-user-endpoint

Conversation

@nemsys54

@nemsys54 nemsys54 commented Jul 7, 2026

Copy link
Copy Markdown

No description provided.

nemsys54 and others added 3 commits July 6, 2026 22:33
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>
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.

1 participant