@mttickets12/common 1.0.8 → 1.0.10

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.
@@ -0,0 +1,9 @@
1
+ import { CustomError } from "./custom-error";
2
+ export declare class BadRequestError extends CustomError {
3
+ message: string;
4
+ statusCode: number;
5
+ constructor(message: string);
6
+ serializeErrors(): {
7
+ message: string;
8
+ }[];
9
+ }
@@ -0,0 +1,8 @@
1
+ export declare abstract class CustomError extends Error {
2
+ abstract statusCode: number;
3
+ constructor(message: string);
4
+ abstract serializeErrors(): {
5
+ message: string;
6
+ field?: string;
7
+ }[];
8
+ }
@@ -0,0 +1,9 @@
1
+ import { CustomError } from "./custom-error";
2
+ export declare class DatabaseConnectionError extends CustomError {
3
+ reason: string;
4
+ statusCode: number;
5
+ constructor();
6
+ serializeErrors(): {
7
+ message: string;
8
+ }[];
9
+ }
@@ -0,0 +1,9 @@
1
+ import { CustomError } from "./custom-error";
2
+ export default class NotAuthorizedError extends CustomError {
3
+ statusCode: number;
4
+ constructor();
5
+ serializeErrors(): {
6
+ message: string;
7
+ field?: string;
8
+ }[];
9
+ }
@@ -0,0 +1,8 @@
1
+ import { CustomError } from "./custom-error";
2
+ export declare class NotFoundError extends CustomError {
3
+ statusCode: number;
4
+ constructor();
5
+ serializeErrors(): {
6
+ message: string;
7
+ }[];
8
+ }
@@ -0,0 +1,11 @@
1
+ import { ValidationError } from "express-validator";
2
+ import { CustomError } from "./custom-error";
3
+ export declare class RequestValidationError extends CustomError {
4
+ errors: ValidationError[];
5
+ statusCode: number;
6
+ constructor(errors: ValidationError[]);
7
+ serializeErrors(): {
8
+ message: any;
9
+ field: string;
10
+ }[];
11
+ }
@@ -0,0 +1,10 @@
1
+ export * from "./errors/bad-request-error";
2
+ export * from "./errors/custom-error";
3
+ export * from "./errors/database-validation-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/validate-request";
8
+ export * from "./middlewares/current-user";
9
+ export * from "./middlewares/error-handler";
10
+ export * from "./middlewares/require-auth";
@@ -0,0 +1,14 @@
1
+ import { NextFunction, Response, Request } from "express";
2
+ interface UserPayload {
3
+ email: string;
4
+ id: string;
5
+ }
6
+ declare global {
7
+ namespace Express {
8
+ interface Request {
9
+ currentUser?: UserPayload;
10
+ }
11
+ }
12
+ }
13
+ export declare const currentUser: (req: Request, res: Response, next: NextFunction) => void;
14
+ export {};
@@ -0,0 +1,2 @@
1
+ import { NextFunction, Response, Request } from "express";
2
+ export declare const errorHandler: (err: Error, req: Request, res: Response, next: NextFunction) => Response<any, Record<string, any>> | undefined;
@@ -0,0 +1,2 @@
1
+ import { NextFunction, Response, Request } from "express";
2
+ export declare const requireAuth: (req: Request, res: Response, next: NextFunction) => void;
@@ -0,0 +1,2 @@
1
+ import { NextFunction, Response, Request } from "express";
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": "@mttickets12/common",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "main": "./build/index.js",
5
5
  "types": "./build/index.d.ts",
6
6
  "type": "module",