MCPcopy Create free account
hub / github.com/NicolasPereira/nodejs-api-tcc / MeController

Class MeController

src/users/controllers/MeController.js:4–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2import { StatusCodes } from "http-status-codes";
3
4export class MeController {
5 async handle(req, res) {
6 const user = await findUserById(req.userId);
7
8 if (!user) {
9 return res
10 .status(StatusCodes.NOT_FOUND)
11 .json({
12 error: true,
13 message: "Usuário não encontrado",
14 });
15 }
16
17 return res
18 .status(StatusCodes.OK)
19 .json({
20 id: user.id,
21 name: user.name,
22 email: user.email,
23 });
24 }
25}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected