Skip to content

Add PUT endpoint to update existing users - #104

Open
rolex17 wants to merge 2 commits into
mate-academy:mainfrom
rolex17:main
Open

Add PUT endpoint to update existing users#104
rolex17 wants to merge 2 commits into
mate-academy:mainfrom
rolex17:main

Conversation

@rolex17

@rolex17 rolex17 commented Aug 25, 2026

Copy link
Copy Markdown

Summary

Implements a PUT endpoint to update existing users with their name and email. The implementation includes proper validation and error handling to match the existing POST endpoint pattern.

Changes

  • Added updateUser() function to db/store.js that finds and updates a user by ID
  • Added PUT route handler in routes/users.js with validation for required fields

Testing

All tests passing:

  • ✅ Updates an existing user and returns 200 with updated data
  • ✅ Returns 404 when user doesn't exist
  • ✅ Returns 400 when required fields are missing

Notes

  • Implementation follows the existing POST endpoint pattern for consistency
  • Validation ensures both name and email are provided before updating

Claude and others added 2 commits August 24, 2026 15:14
Adds a new PUT /users/:id endpoint that:
- Updates an existing user's name and email
- Validates that both fields are provided (400 if missing)
- Returns 404 if the user doesn't exist
- Returns the updated user with 200 status

Implements updateUser() in db/store.js to handle the data persistence,
following the existing pattern used by createUser and getUserById.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Add PUT endpoint to update existing users
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