@jpbs/common 1.1.4 → 1.1.5

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.
@@ -5,10 +5,9 @@ const http_status_codes_1 = require("http-status-codes");
5
5
  const custom_error_1 = require("./custom-error");
6
6
  class BadRequestError extends custom_error_1.CustomError {
7
7
  constructor(message = "Bad request") {
8
- super(message);
8
+ super(message, BadRequestError.prototype);
9
9
  this.message = message;
10
10
  this.statusCode = http_status_codes_1.StatusCodes.BAD_REQUEST;
11
- Object.setPrototypeOf(this, BadRequestError.prototype);
12
11
  }
13
12
  serializeErrors() {
14
13
  return [{ message: this.message }];
@@ -1,6 +1,6 @@
1
1
  export declare abstract class CustomError extends Error {
2
2
  abstract statusCode: number;
3
- constructor(message: string);
3
+ constructor(message: string, prototype: typeof CustomError.prototype);
4
4
  abstract serializeErrors(): {
5
5
  message: string;
6
6
  field?: string;
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CustomError = void 0;
4
4
  class CustomError extends Error {
5
- constructor(message) {
5
+ constructor(message, prototype) {
6
6
  super(message);
7
- Object.setPrototypeOf(this, CustomError.prototype);
7
+ Object.setPrototypeOf(this, prototype);
8
8
  }
9
9
  }
10
10
  exports.CustomError = CustomError;
@@ -5,9 +5,8 @@ const http_status_codes_1 = require("http-status-codes");
5
5
  const custom_error_1 = require("./custom-error");
6
6
  class EmailError extends custom_error_1.CustomError {
7
7
  constructor(message) {
8
- super(message);
8
+ super(message, EmailError.prototype);
9
9
  this.statusCode = http_status_codes_1.StatusCodes.INTERNAL_SERVER_ERROR;
10
- Object.setPrototypeOf(this, EmailError.prototype);
11
10
  }
12
11
  serializeErrors() {
13
12
  return [{ message: this.message }];
@@ -5,10 +5,9 @@ const http_status_codes_1 = require("http-status-codes");
5
5
  const custom_error_1 = require("./custom-error");
6
6
  class NotAuthorizedError extends custom_error_1.CustomError {
7
7
  constructor(message = "Not authorized") {
8
- super(message);
8
+ super(message, NotAuthorizedError.prototype);
9
9
  this.message = message;
10
10
  this.statusCode = http_status_codes_1.StatusCodes.UNAUTHORIZED;
11
- Object.setPrototypeOf(this, NotAuthorizedError.prototype);
12
11
  }
13
12
  serializeErrors() {
14
13
  return [{ message: this.message }];
@@ -5,10 +5,9 @@ const http_status_codes_1 = require("http-status-codes");
5
5
  const custom_error_1 = require("./custom-error");
6
6
  class NotFoundError extends custom_error_1.CustomError {
7
7
  constructor(message = "Resource not found") {
8
- super(message);
8
+ super(message, NotFoundError.prototype);
9
9
  this.message = message;
10
10
  this.statusCode = http_status_codes_1.StatusCodes.NOT_FOUND;
11
- Object.setPrototypeOf(this, NotFoundError.prototype);
12
11
  }
13
12
  serializeErrors() {
14
13
  return [{ message: this.message }];
@@ -5,10 +5,9 @@ const custom_error_1 = require("./custom-error");
5
5
  const http_status_codes_1 = require("http-status-codes");
6
6
  class RequestValidationError extends custom_error_1.CustomError {
7
7
  constructor(errors) {
8
- super('Invalid request parameters');
8
+ super('Invalid request parameters', RequestValidationError.prototype);
9
9
  this.errors = errors;
10
10
  this.statusCode = http_status_codes_1.StatusCodes.BAD_REQUEST;
11
- Object.setPrototypeOf(this, RequestValidationError.prototype);
12
11
  }
13
12
  serializeErrors() {
14
13
  return this.errors.map(err => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jpbs/common",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "main": "./build/index.js",
5
5
  "types": "./build/index.d.ts",
6
6
  "files": [