@wrcb/cb-common 1.0.87 → 1.0.89

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,8 @@
1
1
  import { CustomError } from './customError';
2
2
  export declare class NotFoundError extends CustomError {
3
+ message: string;
3
4
  statusCode: number;
4
- constructor();
5
+ constructor(message: string);
5
6
  serializeErrors(): {
6
7
  message: string;
7
8
  }[];
@@ -3,13 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NotFoundError = void 0;
4
4
  const customError_1 = require("./customError");
5
5
  class NotFoundError extends customError_1.CustomError {
6
- constructor() {
7
- super('Route Not Found');
6
+ constructor(message) {
7
+ super(message);
8
+ this.message = message;
8
9
  this.statusCode = 404;
9
10
  Object.setPrototypeOf(this, NotFoundError.prototype);
10
11
  }
11
12
  serializeErrors() {
12
- return [{ message: 'Not found' }];
13
+ return [{ message: this.message }];
13
14
  }
14
15
  }
15
16
  exports.NotFoundError = NotFoundError;
@@ -11,12 +11,10 @@ const currentUser = (req, res, next) => {
11
11
  // e setar no currentUser property
12
12
  // se não tiver logado, outro middleware irá retornar um erro.
13
13
  if (!((_a = req.session) === null || _a === void 0 ? void 0 : _a.jwt)) {
14
- console.log('entrou a qui----');
15
14
  return next();
16
15
  }
17
16
  try {
18
17
  const payload = jsonwebtoken_1.default.verify(req.session.jwt, process.env.JWT_KEY);
19
- console.log('payload no currentUser', payload);
20
18
  req.currentUser = payload;
21
19
  }
22
20
  catch (error) { }
@@ -6,7 +6,6 @@ const errorHandler = (err, req, res, next) => {
6
6
  if (err instanceof customError_1.CustomError) {
7
7
  return res.status(err.statusCode).send({ errors: err.serializeErrors() });
8
8
  }
9
- console.error('err===========-----------', err);
10
9
  res.status(400).send({ errors: [{ message: 'Something went wrong' }] });
11
10
  };
12
11
  exports.errorHandler = errorHandler;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrcb/cb-common",
3
- "version": "1.0.87",
3
+ "version": "1.0.89",
4
4
  "description": "Common resources between services",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",