exodus-framework 2.0.744 → 2.0.746

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
  }
@@ -9,7 +9,13 @@ export declare class ApplicationHttpException extends ExodusErrorBase {
9
9
  readonly level: TApplicationResponse;
10
10
  data: unknown;
11
11
  error: Error;
12
- constructor(message: string, statusCode?: EHttpResponseCode, level?: TApplicationResponse, data?: unknown, error?: Error);
12
+ constructor(data: {
13
+ message: string;
14
+ statusCode?: EHttpResponseCode;
15
+ level?: TApplicationResponse;
16
+ data?: unknown;
17
+ error?: Error;
18
+ });
13
19
  private handle;
14
20
  }
15
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,oBAAoB,EAAE,M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OAAO,CAAC;QACf,KAAK,CAAC,EAAE,KAAK,CAAC;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"}
@@ -19,13 +19,13 @@ class ApplicationHttpException extends ExodusErrorBase {
19
19
  level;
20
20
  data;
21
21
  error;
22
- constructor(message, statusCode = _http.EHttpResponseCode.iternalErro, level = 'error', data, error) {
22
+ constructor(data) {
23
23
  super();
24
- this.message = message;
25
- this.statusCode = statusCode;
26
- this.level = level;
27
- this.data = data;
28
- this.error = error;
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;
29
29
  this.handle();
30
30
  }
31
31
  handle() {
@@ -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,aAAa;IAIb,YAAY,CAAC,WAAW,EAAE,aAAa,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,YAAY;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E,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,20 +25,19 @@ 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)({
35
31
  logger: (0, _logger.default)()
36
32
  }));
37
- // expss.use(pino);
38
33
  expss.set('query parser', str => _qs.default.parse(str));
39
34
  expss.use(this.responseTypeMiddleware.bind(this));
40
- expss.use(_express.default.json());
35
+ expss.use(_express.default.json({
36
+ limit: '10mb'
37
+ }));
41
38
  expss.use(_express.default.urlencoded({
42
- extended: false
39
+ extended: true,
40
+ limit: '10mb'
43
41
  }));
44
42
  expss.use((0, _cors.default)({
45
43
  origin: '*'
@@ -103,7 +101,10 @@ class ExpressService extends _service.default {
103
101
  }
104
102
  handleAuthorizationFailure(err, req, res, next) {
105
103
  if (err.name === 'UnauthorizedError') {
106
- throw new _error.ApplicationHttpException('Falha na autorização', _http2.EHttpResponseCode.informationUnauthorized);
104
+ throw new _error.ApplicationHttpException({
105
+ message: 'Falha na autorização',
106
+ statusCode: _http2.EHttpResponseCode.informationUnauthorized
107
+ });
107
108
  } else {
108
109
  next(err);
109
110
  }
@@ -135,8 +136,13 @@ class ExpressService extends _service.default {
135
136
  need.push(key);
136
137
  }
137
138
  }
138
- if (!pass) throw new _error.ApplicationHttpException('Requisição incompleta', _http2.EHttpResponseCode.incompleteRequest, 'error', {
139
- need
139
+ if (!pass) throw new _error.ApplicationHttpException({
140
+ message: 'Requisição incompleta',
141
+ statusCode: _http2.EHttpResponseCode.incompleteRequest,
142
+ level: 'error',
143
+ data: {
144
+ need
145
+ }
140
146
  });
141
147
  }
142
148
  registerRouter(router) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "exodus-framework",
3
- "version": "2.0.744",
3
+ "version": "2.0.746",
4
4
  "description": "Exodus Framework",
5
5
  "author": "jhownpaixao",
6
6
  "license": "ISC",