@cs-tickets/common 1.0.3 → 1.0.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.
@@ -1,4 +1,4 @@
1
- import { CustomError } from "./custom-error";
1
+ import { CustomError } from './custom-error';
2
2
  export declare class BadRequestError extends CustomError {
3
3
  message: string;
4
4
  statusCode: number;
@@ -1,4 +1,4 @@
1
- import { CustomError } from "./custom-error";
1
+ import { CustomError } from './custom-error';
2
2
  export declare class DatabaseConnectionError extends CustomError {
3
3
  statusCode: number;
4
4
  reason: string;
@@ -6,7 +6,7 @@ class DatabaseConnectionError extends custom_error_1.CustomError {
6
6
  constructor() {
7
7
  super();
8
8
  this.statusCode = 500;
9
- this.reason = "Failed to connect to database";
9
+ this.reason = 'Failed to connect to database';
10
10
  Object.setPrototypeOf(this, DatabaseConnectionError.prototype);
11
11
  }
12
12
  serializeErrors() {
@@ -1,4 +1,4 @@
1
- import { CustomError } from "./custom-error";
1
+ import { CustomError } from './custom-error';
2
2
  export declare class NotAuthorizedError extends CustomError {
3
3
  statusCode: number;
4
4
  constructor();
@@ -9,7 +9,7 @@ class NotAuthorizedError extends custom_error_1.CustomError {
9
9
  Object.setPrototypeOf(this, NotAuthorizedError.prototype);
10
10
  }
11
11
  serializeErrors() {
12
- return [{ message: "Not authorized" }];
12
+ return [{ message: 'Not authorized' }];
13
13
  }
14
14
  }
15
15
  exports.NotAuthorizedError = NotAuthorizedError;
@@ -1,4 +1,4 @@
1
- import { CustomError } from "./custom-error";
1
+ import { CustomError } from './custom-error';
2
2
  export declare class NotFoundError extends CustomError {
3
3
  statusCode: number;
4
4
  constructor();
@@ -9,7 +9,7 @@ class NotFoundError extends custom_error_1.CustomError {
9
9
  Object.setPrototypeOf(this, NotFoundError.prototype);
10
10
  }
11
11
  serializeErrors() {
12
- return [{ message: "Not Found" }];
12
+ return [{ message: 'Not Found' }];
13
13
  }
14
14
  }
15
15
  exports.NotFoundError = NotFoundError;
@@ -1,5 +1,5 @@
1
- import { ValidationError } from "express-validator";
2
- import { CustomError } from "./custom-error";
1
+ import { ValidationError } from 'express-validator';
2
+ import { CustomError } from './custom-error';
3
3
  export declare class RequestValidationError extends CustomError {
4
4
  errors: ValidationError[];
5
5
  statusCode: number;
@@ -12,7 +12,7 @@ class RequestValidationError extends custom_error_1.CustomError {
12
12
  }
13
13
  serializeErrors() {
14
14
  return this.errors
15
- .filter((error) => error.type === "field")
15
+ .filter((error) => error.type === 'field')
16
16
  .map((error) => {
17
17
  return { message: error.msg, field: error.path };
18
18
  });
package/build/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export * from "./errors/bad-request-error";
2
- export * from "./errors/custom-error";
3
- export * from "./errors/database-connection-error";
4
- export * from "./errors/not-authorized-error";
5
- export * from "./errors/not-found-error";
6
- export * from "./errors/request-validation-error";
7
- export * from "./middlewares/current-user";
8
- export * from "./middlewares/error-handler";
9
- export * from "./middlewares/require-auth";
10
- export * from "./middlewares/validate-request";
1
+ export * from './errors/bad-request-error';
2
+ export * from './errors/custom-error';
3
+ export * from './errors/database-connection-error';
4
+ export * from './errors/not-authorized-error';
5
+ export * from './errors/not-found-error';
6
+ export * from './errors/request-validation-error';
7
+ export * from './middlewares/current-user';
8
+ export * from './middlewares/error-handler';
9
+ export * from './middlewares/require-auth';
10
+ export * from './middlewares/validate-request';
@@ -1,4 +1,4 @@
1
- import { Request, Response, NextFunction } from "express";
1
+ import { Request, Response, NextFunction } from 'express';
2
2
  interface UserPayload {
3
3
  id: string;
4
4
  email: string;
@@ -1,2 +1,2 @@
1
- import { Request, Response, NextFunction } from "express";
1
+ import { Request, Response, NextFunction } from 'express';
2
2
  export declare const errorHandler: (err: Error, req: Request, res: Response, next: NextFunction) => void;
@@ -7,10 +7,11 @@ const errorHandler = (err, req, res, next) => {
7
7
  res.status(err.statusCode).send({ errors: err.serializeErrors() });
8
8
  return;
9
9
  }
10
+ console.error(err);
10
11
  res.status(400).send({
11
12
  errors: [
12
13
  {
13
- message: "Something went wrong",
14
+ message: 'Something went wrong',
14
15
  },
15
16
  ],
16
17
  });
@@ -1,2 +1,2 @@
1
- import { Request, Response, NextFunction } from "express";
1
+ import { Request, Response, NextFunction } from 'express';
2
2
  export declare const requireAuth: (req: Request, res: Response, next: NextFunction) => void;
@@ -1,2 +1,2 @@
1
- import { Request, Response, NextFunction } from "express";
1
+ import { Request, Response, NextFunction } from 'express';
2
2
  export declare const validateRequest: (req: Request, res: Response, next: NextFunction) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cs-tickets/common",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",