MCPcopy Create free account
hub / github.com/RealDevSquad/website-backend / getUserStatus

Function getUserStatus

controllers/userStatus.js:45–68  ·  view source on GitHub ↗
(req, res)

Source from the content-addressed store, hash-verified

43 * @param req {Object} - Express request object
44 * @param res {Object} - Express response object
45 */
46const getUserStatus = async (req, res) => {
47 try {
48 const userId = getUserIdBasedOnRoute(req);
49 if (userId) {
50 const userData = await userStatusModel.getUserStatus(userId);
51 const { userStatusExists, id, data } = userData;
52 const responseObject = { id, userId, data: null, message: "" };
53 if (data) responseObject.data = data;
54 let statusCode;
55 if (userStatusExists) {
56 statusCode = 200;
57 responseObject.message = "User Status found successfully.";
58 } else {
59 statusCode = 404;
60 responseObject.message = "User Status couldn't be found.";
61 }
62 return res.status(statusCode).json(responseObject);
63 }
64 return res.boom.notFound("User Status doesn't exist.");
65 } catch (err) {
66 logger.error(`Error while fetching the User Status: ${err}`);
67 return res.boom.notFound("The User Status could not be found as an internal server error occurred.");
68 }
69};
70
71/**

Callers 3

getUsersFunction · 0.70

Calls 1

getUserIdBasedOnRouteFunction · 0.85

Tested by

no test coverage detected