c2-http 1.0.160 → 1.0.161

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.
@@ -1,7 +1,6 @@
1
1
  import { NextFunction, Request, Response } from "express";
2
2
  declare class MiddlewareCheckTokenFlow {
3
3
  execute(request: Request, response: Response, next: NextFunction): Promise<void>;
4
- checkToken(): Promise<void>;
5
4
  }
6
5
  declare const _default: MiddlewareCheckTokenFlow;
7
6
  export default _default;
@@ -11,6 +11,17 @@ const ValidateTokenFlowItem_1 = __importDefault(require("./item/ValidateTokenFlo
11
11
  const c2_util_1 = require("c2-util");
12
12
  class MiddlewareCheckTokenFlow {
13
13
  async execute(request, response, next) {
14
+ const checkToken = async () => {
15
+ let token = "";
16
+ try {
17
+ token = GetTokenFlowItem_1.default.get();
18
+ const tokenDecoded = await ValidateTokenFlowItem_1.default.exec(token);
19
+ AddInContextFlowItem_1.default.exec(tokenDecoded, token);
20
+ }
21
+ catch (error) {
22
+ throw (0, __1.convertErrorToHttpError)(error);
23
+ }
24
+ };
14
25
  try {
15
26
  if ((request.path === "/metrics" ||
16
27
  request.path.startsWith("/metrics") ||
@@ -23,7 +34,7 @@ class MiddlewareCheckTokenFlow {
23
34
  next();
24
35
  return;
25
36
  }
26
- await this.checkToken();
37
+ await checkToken();
27
38
  return next();
28
39
  }
29
40
  catch (error) {
@@ -33,16 +44,5 @@ class MiddlewareCheckTokenFlow {
33
44
  .json({ message: error.message, detail: error.detail?.data });
34
45
  }
35
46
  }
36
- async checkToken() {
37
- let token = "";
38
- try {
39
- token = GetTokenFlowItem_1.default.get();
40
- const tokenDecoded = await ValidateTokenFlowItem_1.default.exec(token);
41
- AddInContextFlowItem_1.default.exec(tokenDecoded, token);
42
- }
43
- catch (error) {
44
- throw (0, __1.convertErrorToHttpError)(error);
45
- }
46
- }
47
47
  }
48
48
  exports.default = new MiddlewareCheckTokenFlow;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "c2-http",
3
- "version": "1.0.160",
3
+ "version": "1.0.161",
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>",