c2-http 1.0.126 → 1.0.128

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,7 +18,7 @@ class MiddlewareCheckScopesFlow {
18
18
  response
19
19
  .status(http_status_1.UNAUTHORIZED)
20
20
  .json({ message: (0, i18n_1.getMessage)("message.authorization.userAccessNotAllowed", scopesRequireds?.join(", ")) });
21
- return;
21
+ return next((0, i18n_1.getMessage)("message.authorization.userAccessNotAllowed", scopesRequireds?.join(", ")));
22
22
  }
23
23
  next();
24
24
  };
@@ -23,12 +23,13 @@ class MiddlewareCheckTokenFlow {
23
23
  next();
24
24
  return;
25
25
  }
26
- await this.checkToken(response, next);
26
+ return await this.checkToken(response, next);
27
27
  }
28
28
  catch (error) {
29
29
  response
30
30
  .status(error.status || http_status_1.INTERNAL_SERVER_ERROR)
31
31
  .json({ message: error.message, detail: error.detail?.data });
32
+ return next(error);
32
33
  }
33
34
  };
34
35
  async checkToken(response, next) {
@@ -43,6 +43,21 @@ class Controller {
43
43
  if (middlewares) {
44
44
  middlewaresAux = [...middlewaresAux, ...middlewares];
45
45
  }
46
+ // Imprime a sequência de execução dos middlewares
47
+ const fullPath = `${this.uri}${uri}`;
48
+ console.log(`\n[Controller] Rota registrada: ${method.toUpperCase()} ${fullPath}`);
49
+ if (middlewaresAux.length > 0) {
50
+ const sequenciaMsg = " Sequência de execução dos middlewares:";
51
+ console.log(sequenciaMsg);
52
+ middlewaresAux.forEach((middleware, index) => {
53
+ const middlewareName = middleware.name || "Anonymous Middleware";
54
+ console.log(` ${index + 1}. ${middlewareName}`);
55
+ });
56
+ console.log(` ${middlewaresAux.length + 1}. Handler (${handlerFn.name || "Anonymous Handler"})`);
57
+ }
58
+ else {
59
+ console.log(` Handler: ${handlerFn.name || "Anonymous Handler"} (sem middlewares)`);
60
+ }
46
61
  // Registra rota normalmente
47
62
  this.router[method](uri, ...middlewaresAux, handlerFn);
48
63
  if (uri.includes(":")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-http",
3
- "version": "1.0.126",
3
+ "version": "1.0.128",
4
4
  "description": "Biblioteca Typescript para API NodeJS",
5
5
  "repository": "https://cabralsilva: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@github.com/cabralsilva/c2-http.git",
6
6
  "author": "Daniel Cabral <cabralconsultoriaemsoftware@gmail.com>",