MCPcopy Create free account
hub / github.com/dhatGuy/PERN-Store / getUserById

Function getUserById

server/controllers/users.controller.js:27–38  ·  view source on GitHub ↗
(req, res)

Source from the content-addressed store, hash-verified

25};
26
27const getUserById = async (req, res) => {
28 const { id } = req.params;
29 if (+id === req.user.id || req.user.roles.includes("admin")) {
30 try {
31 const user = await userService.getUserById(id);
32 return res.status(200).json(user);
33 } catch (error) {
34 throw new ErrorHandler(error.statusCode, "User not found");
35 }
36 }
37 throw new ErrorHandler(401, "Unauthorized");
38};
39
40const getUserProfile = async (req, res) => {
41 const { id } = req.user;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected