Skip to content

Commit

Permalink
Merge pull request #6 from mrlazyg/dev
Browse files Browse the repository at this point in the history
user route
  • Loading branch information
noorsalimx authored Mar 7, 2024
2 parents 132903a + ed717b2 commit 4ebf0ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions controllers/UserController.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@ const getAllUsers = (req, res) => {
};

const getUser = (req, res) => {
const { userId } = req.params;
const user = users.find((id) => userId === id.email || userId === id._id);
if (!user) {
return res.status(404).send({
status: 'error',
message: 'user not found',
});
}
res.send({
status: 'success',
user: user || 'User not found',
});
};

Expand Down
2 changes: 1 addition & 1 deletion routes/UserRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ router
.get(UserController.getAllUsers)
.post(UserController.createUser);
router
.route('/:id')
.route('/:userId')
.get(UserController.getUser)
.patch(UserController.updateUser)
.delete(UserController.deleteUser);
Expand Down

0 comments on commit 4ebf0ad

Please sign in to comment.