Skip to content

Commit 4f3eebc

Browse files
Add updateUser store helper for PUT /users/:id
Finds a user by id and updates their name/email in place, returning undefined when no user matches so the route layer can 404. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent c0ca7e9 commit 4f3eebc

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

db/store.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,16 @@ function createUser({ name, email }) {
2424
return user;
2525
}
2626

27-
module.exports = { getAllUsers, getUserById, createUser };
27+
function updateUser(id, { name, email }) {
28+
const user = getUserById(id);
29+
30+
if (!user) {
31+
return undefined;
32+
}
33+
34+
user.name = name;
35+
user.email = email;
36+
return user;
37+
}
38+
39+
module.exports = { getAllUsers, getUserById, createUser, updateUser };

0 commit comments

Comments
 (0)