@jpbs/common 1.1.0 → 1.1.1

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,10 @@
1
+ import { StatusCodes } from "http-status-codes";
2
+ import { CustomError } from "./custom-error";
3
+ export declare class BadRequestError extends CustomError {
4
+ message: string;
5
+ statusCode: StatusCodes;
6
+ constructor(message?: string);
7
+ serializeErrors(): {
8
+ message: string;
9
+ }[];
10
+ }
@@ -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 { StatusCodes } from "http-status-codes";
2
+ import { CustomError } from "./custom-error";
3
+ export declare class EmailError extends CustomError {
4
+ statusCode: StatusCodes;
5
+ constructor(message: string);
6
+ serializeErrors(): {
7
+ message: string;
8
+ }[];
9
+ }
@@ -0,0 +1,10 @@
1
+ import { StatusCodes } from "http-status-codes";
2
+ import { CustomError } from "./custom-error";
3
+ export declare class NotAuthorizedError extends CustomError {
4
+ message: string;
5
+ statusCode: StatusCodes;
6
+ constructor(message?: string);
7
+ serializeErrors(): {
8
+ message: string;
9
+ }[];
10
+ }
@@ -0,0 +1,10 @@
1
+ import { StatusCodes } from "http-status-codes";
2
+ import { CustomError } from "./custom-error";
3
+ export declare class NotFoundError extends CustomError {
4
+ message: string;
5
+ statusCode: StatusCodes;
6
+ constructor(message?: string);
7
+ serializeErrors(): {
8
+ message: string;
9
+ }[];
10
+ }
@@ -0,0 +1,11 @@
1
+ import { ValidationError } from "express-validator";
2
+ import { CustomError } from "./custom-error";
3
+ import { StatusCodes } from "http-status-codes";
4
+ export declare class RequestValidationError extends CustomError {
5
+ private errors;
6
+ statusCode: StatusCodes;
7
+ constructor(errors: ValidationError[]);
8
+ serializeErrors(): {
9
+ message: any;
10
+ }[];
11
+ }
@@ -0,0 +1,10 @@
1
+ export * from './errors/custom-error';
2
+ export * from './errors/notfound-error';
3
+ export * from './errors/notauthorized-error';
4
+ export * from './errors/bad-request-error';
5
+ export * from './errors/request-validation';
6
+ export * from './middlewares/asyncHandler';
7
+ export * from './middlewares/authProtect';
8
+ export * from './middlewares/errorHandler';
9
+ export * from './middlewares/validateRequest';
10
+ export * from './middlewares/verifyGatewayToken';
@@ -0,0 +1,2 @@
1
+ import { Request, Response, NextFunction } from "express";
2
+ export declare const asyncHandler: (fn: any) => (req: Request, res: Response, next: NextFunction) => void;
@@ -0,0 +1,16 @@
1
+ import { Request, Response, NextFunction } from "express";
2
+ export declare enum Role {
3
+ ADMINISTRATOR = "Administrator",
4
+ USER = "User"
5
+ }
6
+ export interface AuthenticatedRequest extends Request {
7
+ currentUser?: IDecodedUser;
8
+ }
9
+ interface IDecodedUser {
10
+ id: string;
11
+ email: string;
12
+ username: string;
13
+ role: Role;
14
+ }
15
+ export declare const authenticationGuard: (jwtSecret: string) => (req: AuthenticatedRequest, res: Response, next: NextFunction) => void;
16
+ export {};
@@ -0,0 +1,2 @@
1
+ import { Request, Response, NextFunction } from 'express';
2
+ export declare const errorHandler: (err: Error, _req: Request, res: Response, _next: NextFunction) => void;
@@ -0,0 +1,5 @@
1
+ import { Request, Response, NextFunction } from 'express';
2
+ export declare const validateSignup: import("express-validator").ValidationChain[];
3
+ export declare const validateLogin: import("express-validator").ValidationChain[];
4
+ export declare const validateUpdateUser: import("express-validator").ValidationChain[];
5
+ export declare const validateRequest: (req: Request, _res: Response, next: NextFunction) => void;
@@ -0,0 +1,2 @@
1
+ import { Request, Response, NextFunction } from "express";
2
+ export declare const verifyGatewayToken: (gatewaySecret: string) => (req: Request, _res: Response, next: NextFunction) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jpbs/common",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "main": "./build/index.js",
5
5
  "types": "./build/index.d.ts",
6
6
  "files": [