c2-http 1.0.129 → 1.0.130

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.
@@ -7,18 +7,16 @@ exports.MiddlewareCheckScopesFlow = void 0;
7
7
  const express_http_context_1 = __importDefault(require("express-http-context"));
8
8
  const http_status_1 = require("http-status");
9
9
  const i18n_1 = require("../../i18n");
10
- const c2_util_1 = require("c2-util");
11
10
  class MiddlewareCheckScopesFlow {
12
11
  exec = (scopesRequireds) => {
13
12
  return async (_request, response, next) => {
14
13
  const scopesOfUser = express_http_context_1.default.get("scopes");
15
14
  const hasRole = scopesRequireds.some((scopeRequired) => scopesOfUser?.split(" ").includes(scopeRequired));
16
15
  if (!hasRole) {
17
- (0, c2_util_1.log)("LOG_ERROR_CHECK_SCOPES", { scopesRequireds, scopesOfUser });
18
16
  response
19
17
  .status(http_status_1.UNAUTHORIZED)
20
18
  .json({ message: (0, i18n_1.getMessage)("message.authorization.userAccessNotAllowed", scopesRequireds?.join(", ")) });
21
- return next((0, i18n_1.getMessage)("message.authorization.userAccessNotAllowed", scopesRequireds?.join(", ")));
19
+ return;
22
20
  }
23
21
  next();
24
22
  };
@@ -8,7 +8,6 @@ const __1 = require("../..");
8
8
  const AddInContextFlowItem_1 = __importDefault(require("./item/AddInContextFlowItem"));
9
9
  const GetTokenFlowItem_1 = __importDefault(require("./item/GetTokenFlowItem"));
10
10
  const ValidateTokenFlowItem_1 = __importDefault(require("./item/ValidateTokenFlowItem"));
11
- const c2_util_1 = require("c2-util");
12
11
  class MiddlewareCheckTokenFlow {
13
12
  config = async (request, response, next) => {
14
13
  try {
@@ -23,13 +22,12 @@ class MiddlewareCheckTokenFlow {
23
22
  next();
24
23
  return;
25
24
  }
26
- return await this.checkToken(response, next);
25
+ await this.checkToken(response, next);
27
26
  }
28
27
  catch (error) {
29
28
  response
30
29
  .status(error.status || http_status_1.INTERNAL_SERVER_ERROR)
31
30
  .json({ message: error.message, detail: error.detail?.data });
32
- return next(error);
33
31
  }
34
32
  };
35
33
  async checkToken(response, next) {
@@ -41,7 +39,6 @@ class MiddlewareCheckTokenFlow {
41
39
  next();
42
40
  }
43
41
  catch (error) {
44
- (0, c2_util_1.log)("LOG_ERROR_CHECK_TOKEN", error);
45
42
  throw (0, __1.convertErrorToHttpError)(error);
46
43
  }
47
44
  }
@@ -43,23 +43,6 @@ class Controller {
43
43
  if (middlewares) {
44
44
  middlewaresAux = [...middlewaresAux, ...middlewares];
45
45
  }
46
- if (this.uri.includes("/settings")) {
47
- // Imprime a sequência de execução dos middlewares
48
- const fullPath = `${this.uri}${uri}`;
49
- console.log(`\n[Controller] Rota registrada: ${method.toUpperCase()} ${fullPath}`);
50
- if (middlewaresAux.length > 0) {
51
- const sequenciaMsg = " Sequência de execução dos middlewares:";
52
- console.log(sequenciaMsg);
53
- middlewaresAux.forEach((middleware, index) => {
54
- const middlewareName = middleware.name || "Anonymous Middleware";
55
- console.log(` ${index + 1}. ${middlewareName}`);
56
- });
57
- console.log(` ${middlewaresAux.length + 1}. Handler (${handlerFn.name || "Anonymous Handler"})`);
58
- }
59
- else {
60
- console.log(` Handler: ${handlerFn.name || "Anonymous Handler"} (sem middlewares)`);
61
- }
62
- }
63
46
  // Registra rota normalmente
64
47
  this.router[method](uri, ...middlewaresAux, handlerFn);
65
48
  if (uri.includes(":")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-http",
3
- "version": "1.0.129",
3
+ "version": "1.0.130",
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>",