@pxp-nd/core 1.2.74 → 1.2.77

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.
package/dist/PxpApp.js CHANGED
@@ -45,7 +45,7 @@ const modulesPxp = {
45
45
  common: '@pxp-nd/common',
46
46
  reports: '@pxp-nd/reports',
47
47
  };
48
- //auth configure
48
+ //auth configure
49
49
  /**
50
50
  *
51
51
  * */
@@ -125,9 +125,8 @@ class PxpApp {
125
125
  }
126
126
  next();
127
127
  });
128
- this.app.use(express_1.default.json({ limit: '2mb' }));
129
- this.app.use(express_1.default.urlencoded({ limit: '2mb' }));
130
- console.log('llegggga aca nuevo');
128
+ this.app.use(express_1.default.json());
129
+ this.app.use(express_1.default.urlencoded({ extended: false }));
131
130
  this.app.use(express_fileupload_1.default({
132
131
  limits: { fileSize: 5 * 1024 * 1024 },
133
132
  }));
@@ -265,7 +264,7 @@ class PxpApp {
265
264
  if (this.config.auth) {
266
265
  await this.initializeAuthentication(this.configAuth);
267
266
  }
268
- // load ioServer
267
+ // load ioServer
269
268
  this.loadIOserver();
270
269
  // load controllers and routes
271
270
  await this.loadControllers();
@@ -7,6 +7,9 @@ declare interface IAuthLocal {
7
7
  verifyUser: any;
8
8
  fields: IAuthields;
9
9
  }
10
+ declare interface IAuthJWT {
11
+ verifyUser: any;
12
+ }
10
13
  declare interface ISerialize {
11
14
  (userPayload: any, done: any): any;
12
15
  }
@@ -17,7 +20,7 @@ declare interface IAuthPxp {
17
20
  serialize: ISerialize;
18
21
  deserialize: IDeserialize;
19
22
  local?: boolean | IAuthLocal;
20
- jwt?: boolean | any;
23
+ jwt?: boolean | IAuthJWT;
21
24
  }
22
25
  declare interface IModule {
23
26
  entities?: any;
@@ -11,13 +11,13 @@
11
11
  * Created at : 2020-06-13 18:09:48
12
12
  * Last modified : 2020-09-20 18:20:43
13
13
  */
14
- import express from 'express';
14
+ import express from "express";
15
15
  declare class PxpError extends Error {
16
16
  statusCode: number;
17
17
  message: string;
18
18
  tecMessage: string;
19
- errorObject: undefined;
20
- constructor(statusCode: number, message: string, errorObject?: undefined, stack?: undefined);
19
+ errorObject: any;
20
+ constructor(statusCode: number, message: string, errorObject?: any, stack?: undefined);
21
21
  }
22
22
  declare const __: (promise: Promise<any>, myShowError?: boolean) => Promise<any>;
23
23
  declare const errorMiddleware: (err: PxpError, req: express.Request, res: any) => any;
@@ -14,21 +14,26 @@
14
14
  */
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.__ = exports.errorMiddleware = exports.PxpError = void 0;
17
- const genericMessage = 'Web server error. Contact the administrator';
17
+ const genericMessage = "Web server error. Contact the administrator";
18
18
  let showError = false;
19
19
  class PxpError extends Error {
20
- constructor(statusCode, message, errorObject, stack) {
20
+ constructor(statusCode, message, errorObject = undefined, stack) {
21
21
  super();
22
22
  this.statusCode = statusCode;
23
23
  this.message = statusCode === 500 ? genericMessage : message;
24
24
  this.errorObject = errorObject;
25
- this.tecMessage = message;
25
+ if (errorObject && errorObject.response && errorObject.config) {
26
+ this.tecMessage = `Error in Axios call to ${this.errorObject.config.url}, response: ${JSON.stringify(this.errorObject.response.data)}`;
27
+ }
28
+ else {
29
+ this.tecMessage = message;
30
+ }
26
31
  this.stack = stack || this.stack;
27
32
  }
28
33
  }
29
34
  exports.PxpError = PxpError;
30
35
  // Pxp async promise error handler
31
- const __ = (promise, myShowError = false) => (promise
36
+ const __ = (promise, myShowError = false) => promise
32
37
  .then((data) => data)
33
38
  .catch((error) => {
34
39
  showError = myShowError || showError;
@@ -36,21 +41,22 @@ const __ = (promise, myShowError = false) => (promise
36
41
  throw error;
37
42
  }
38
43
  else {
39
- throw new PxpError(showError ? 406 : 500, error.message, undefined, error.stack);
44
+ throw new PxpError(showError ? 406 : 500, error.message, error, error.stack);
40
45
  }
41
- }));
46
+ });
42
47
  exports.__ = __;
43
48
  // error handler middleware
44
49
  const errorMiddleware = (err, req, res) => {
45
50
  const { statusCode, message, stack, tecMessage, errorObject } = err;
46
- const extraObj = process.env.NODE_ENV === 'production' ? {} : { extendedMessage: tecMessage, stack };
51
+ const extraObj = process.env.NODE_ENV === "production"
52
+ ? {}
53
+ : { extendedMessage: tecMessage, stack, errorObject };
47
54
  // @todo if production not show tecMessage and stack
48
55
  return res.status(err.statusCode || 500).json({
49
56
  error: Object.assign({
50
57
  code: statusCode,
51
58
  message,
52
59
  logId: res.logId ? res.logId : undefined,
53
- errorObject,
54
60
  }, extraObj),
55
61
  });
56
62
  };
@@ -36,18 +36,20 @@ const userHasPermission = (Role) => async (userId, transaction) => {
36
36
  };
37
37
  exports.userHasPermission = userHasPermission;
38
38
  const insertLog = async (username, macaddres, ip, logType, desc, proc, trans, query, req, resp, err, timeEx, logConfig) => {
39
- for (const [key, value] of Object.entries(logConfig)) {
40
- if (key in req) {
41
- if (!value) {
42
- delete req[key];
43
- }
44
- else if (value === 'cc_mask') {
45
- const aux = req[key];
46
- req[key] = '************' + aux.substr(-4);
47
- }
48
- else if (value === 'complete_mask') {
49
- const aux = req[key];
50
- req[key] = aux.replace(/./g, '*');
39
+ if (logConfig) {
40
+ for (const [key, value] of Object.entries(logConfig)) {
41
+ if (key in req) {
42
+ if (!value) {
43
+ delete req[key];
44
+ }
45
+ else if (value === 'cc_mask') {
46
+ const aux = req[key];
47
+ req[key] = '************' + aux.substr(-4);
48
+ }
49
+ else if (value === 'complete_mask') {
50
+ const aux = req[key];
51
+ req[key] = aux.replace(/./g, '*');
52
+ }
51
53
  }
52
54
  }
53
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pxp-nd/core",
3
- "version": "1.2.74",
3
+ "version": "1.2.77",
4
4
  "description": "Contains main files for pxp-nd",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",