exodus-framework 2.0.743 → 2.0.745

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 +1 @@
1
- {"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../src/middlewares/access.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAO5C,cAAM,gBAAiB,SAAQ,cAAc;IAC3C,WAAW,UAAW,YAAY,EAAE,KAAG,cAAc,CAWnD;IAEF,SAAS,EAAE,cAAc,CAiDvB;CACH;AAED,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../src/middlewares/access.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAO5C,cAAM,gBAAiB,SAAQ,cAAc;IAC3C,WAAW,UAAW,YAAY,EAAE,KAAG,cAAc,CAWnD;IAEF,SAAS,EAAE,cAAc,CAoDvB;CACH;AAED,eAAe,gBAAgB,CAAC"}
@@ -16,7 +16,10 @@ class AccessMiddleware extends _controller.default {
16
16
  accessLevel = level => {
17
17
  return (req, res, next) => {
18
18
  if (!level.includes(req.auth.account.type)) {
19
- throw new _error.ApplicationHttpException('Nível de acesso não permitido para esta rota.', _http.EHttpResponseCode.informationBlocked);
19
+ throw new _error.ApplicationHttpException({
20
+ message: 'Nível de acesso não permitido para esta rota.',
21
+ statusCode: _http.EHttpResponseCode.informationBlocked
22
+ });
20
23
  }
21
24
  next();
22
25
  };
@@ -35,16 +38,28 @@ class AccessMiddleware extends _controller.default {
35
38
  }
36
39
  });
37
40
  if (!application) {
38
- throw new _error.ApplicationHttpException('Token de aplicação inválido', _http.EHttpResponseCode.informationUnauthorized);
41
+ throw new _error.ApplicationHttpException({
42
+ message: 'Token de aplicação inválido',
43
+ statusCode: _http.EHttpResponseCode.informationUnauthorized
44
+ });
39
45
  } else if (!application.active) {
40
- throw new _error.ApplicationHttpException('Token desativado', _http.EHttpResponseCode.informationBlocked);
46
+ throw new _error.ApplicationHttpException({
47
+ message: 'Token desativado',
48
+ statusCode: _http.EHttpResponseCode.informationBlocked
49
+ });
41
50
  } else if ((0, _dateFns.isBefore)(application.expiresAt, new Date())) {
42
- throw new _error.ApplicationHttpException('Token expirado', _http.EHttpResponseCode.informationBlocked);
51
+ throw new _error.ApplicationHttpException({
52
+ message: 'Token expirado',
53
+ statusCode: _http.EHttpResponseCode.informationBlocked
54
+ });
43
55
  } else {
44
56
  //valido
45
57
  const data = await _security.default.singleton().verifySignature(applicationId, _security.default.singleton().getServicePublicKey());
46
58
  if (!data) {
47
- throw new _error.ApplicationHttpException('Token sem autênticidade.', _http.EHttpResponseCode.informationBlocked);
59
+ throw new _error.ApplicationHttpException({
60
+ message: 'Token sem autênticidade.',
61
+ statusCode: _http.EHttpResponseCode.informationBlocked
62
+ });
48
63
  }
49
64
  envUuid = data.payload.envUuid;
50
65
  }
@@ -8,7 +8,14 @@ export declare class ApplicationHttpException extends ExodusErrorBase {
8
8
  readonly statusCode: number;
9
9
  readonly level: TApplicationResponse;
10
10
  data: unknown;
11
- constructor(message: string, statusCode?: EHttpResponseCode, level?: TApplicationResponse, data?: unknown);
11
+ error: Error;
12
+ constructor(data: {
13
+ message: string;
14
+ statusCode?: EHttpResponseCode;
15
+ level?: TApplicationResponse;
16
+ data?: unknown;
17
+ error?: Error;
18
+ });
12
19
  private handle;
13
20
  }
14
21
  export declare class ApplicationException extends ExodusErrorBase {
@@ -1 +1 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/services/error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,oBAA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;KACf;IAUD,OAAO,CAAC,MAAM;CAKf;AAED,qBAAa,oBAAqB,SAAQ,eAAe;IACvD,SAAgB,OAAO,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,KAAK,CAAC;gBAER,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG;IAOxC,OAAO,CAAC,MAAM;CAKf"}
@@ -18,17 +18,20 @@ class ApplicationHttpException extends ExodusErrorBase {
18
18
  statusCode;
19
19
  level;
20
20
  data;
21
- constructor(message, statusCode = _http.EHttpResponseCode.iternalErro, level = 'error', data) {
21
+ error;
22
+ constructor(data) {
22
23
  super();
23
- this.message = message;
24
- this.statusCode = statusCode;
25
- this.level = level;
26
- this.data = data;
24
+ this.message = data.message;
25
+ this.statusCode = data.statusCode || _http.EHttpResponseCode.iternalErro;
26
+ this.level = data.level || 'error';
27
+ this.data = data.data;
28
+ this.error = data.error;
27
29
  this.handle();
28
30
  }
29
31
  handle() {
30
32
  (0, _logger.default)().warn(this.message, this.statusCode);
31
33
  (0, _logger.default)().warn(this.data);
34
+ this.error && (0, _logger.default)().error(this.error);
32
35
  }
33
36
  }
34
37
  exports.ApplicationHttpException = ApplicationHttpException;
@@ -1 +1 @@
1
- {"version":3,"file":"express.d.ts","sourceRoot":"","sources":["../../src/services/express.ts"],"names":[],"mappings":"AACA,OAAgB,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAqB,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAKhD,cAAM,cAAe,SAAQ,OAAQ,YAAW,QAAQ;IACtD,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,UAAU,CAAS;IAErB,IAAI;IAyBV,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AAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ;IAWzC,0BAA0B,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY;IAUtF,2BAA2B,QACpB,GAAG,OACH,OAAO,OACP,QAAQ,KAEV,YAAY,mBAoBf;IAEI,YAAY,CAAC,MAAM,EAAE,MAAM;IAyBjC,cAAc,CAAC,MAAM,EAAE,MAAM;CAG9B;AAED,eAAe,cAAc,CAAC"}
@@ -6,16 +6,15 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _cors = _interopRequireDefault(require("cors"));
8
8
  var _express = _interopRequireDefault(require("express"));
9
- var _qs = _interopRequireDefault(require("qs"));
10
9
  require("express-async-errors");
10
+ var _expressRequestsLogger = _interopRequireDefault(require("express-requests-logger"));
11
11
  var http = _interopRequireWildcard(require("http"));
12
- var _pinoHttp = _interopRequireDefault(require("pino-http"));
12
+ var _qs = _interopRequireDefault(require("qs"));
13
13
  var _app = require("../app");
14
14
  var _service = _interopRequireDefault(require("../app/service"));
15
15
  var _http2 = require("../contracts/http");
16
16
  var _logger = _interopRequireDefault(require("../utils/logger"));
17
17
  var _error = require("./error");
18
- var _expressRequestsLogger = _interopRequireDefault(require("express-requests-logger"));
19
18
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
20
19
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
21
20
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -26,9 +25,6 @@ class ExpressService extends _service.default {
26
25
  if (!this.mainRouter) throw new _error.ApplicationException('Need router'); //!sem router
27
26
 
28
27
  const expss = (0, _express.default)();
29
- const pino = (0, _pinoHttp.default)({
30
- logger: (0, _logger.default)()
31
- });
32
28
  this.server = http.createServer(expss);
33
29
  expss.use('/public', _express.default.static(_app.Core.settings.getHttp().publicPath));
34
30
  expss.use((0, _expressRequestsLogger.default)({
@@ -103,7 +99,10 @@ class ExpressService extends _service.default {
103
99
  }
104
100
  handleAuthorizationFailure(err, req, res, next) {
105
101
  if (err.name === 'UnauthorizedError') {
106
- throw new _error.ApplicationHttpException('Falha na autorização', _http2.EHttpResponseCode.informationUnauthorized);
102
+ throw new _error.ApplicationHttpException({
103
+ message: 'Falha na autorização',
104
+ statusCode: _http2.EHttpResponseCode.informationUnauthorized
105
+ });
107
106
  } else {
108
107
  next(err);
109
108
  }
@@ -135,8 +134,13 @@ class ExpressService extends _service.default {
135
134
  need.push(key);
136
135
  }
137
136
  }
138
- if (!pass) throw new _error.ApplicationHttpException('Requisição incompleta', _http2.EHttpResponseCode.incompleteRequest, 'error', {
139
- need
137
+ if (!pass) throw new _error.ApplicationHttpException({
138
+ message: 'Requisição incompleta',
139
+ statusCode: _http2.EHttpResponseCode.incompleteRequest,
140
+ level: 'error',
141
+ data: {
142
+ need
143
+ }
140
144
  });
141
145
  }
142
146
  registerRouter(router) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exodus-framework",
3
- "version": "2.0.743",
3
+ "version": "2.0.745",
4
4
  "description": "Exodus Framework",
5
5
  "author": "jhownpaixao",
6
6
  "license": "ISC",