@vrkktickets/common 1.0.2 → 1.0.3

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
+ statusCode: number;
4
+ reason: string;
5
+ constructor();
6
+ serializeErrors(): {
7
+ message: string;
8
+ }[];
9
+ }
@@ -0,0 +1,8 @@
1
+ import { CustomError } from './custom-error';
2
+ export declare class NotAuthorizedError extends CustomError {
3
+ statusCode: number;
4
+ constructor();
5
+ serializeErrors(): {
6
+ message: string;
7
+ }[];
8
+ }
@@ -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,14 @@
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
+ message: any;
12
+ field?: undefined;
13
+ })[];
14
+ }
@@ -0,0 +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';
@@ -0,0 +1,15 @@
1
+ import { Request, Response, NextFunction } from 'express';
2
+ import 'cookie-session';
3
+ interface UserPayload {
4
+ id: string;
5
+ email: string;
6
+ }
7
+ declare global {
8
+ namespace Express {
9
+ interface Request {
10
+ currentUser?: UserPayload;
11
+ }
12
+ }
13
+ }
14
+ export declare const currentUser: (req: Request, res: Response, next: NextFunction) => void;
15
+ export {};
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.currentUser = void 0;
7
7
  const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
8
+ require("cookie-session");
8
9
  const currentUser = (req, res, next) => {
9
10
  var _a;
10
11
  if (!((_a = req.session) === null || _a === void 0 ? void 0 : _a.jwt)) {
@@ -0,0 +1,2 @@
1
+ import { Request, Response, NextFunction } 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 { Request, Response, NextFunction } from 'express';
2
+ export declare const requireAuth: (req: Request, res: Response, next: NextFunction) => void;
@@ -0,0 +1,2 @@
1
+ import { Request, Response, NextFunction } from "express";
2
+ export declare const validateRequest: (req: Request, res: Response, next: NextFunction) => void;
package/package.json CHANGED
@@ -1 +1,30 @@
1
- {"name":"@vrkktickets/common","version":"1.0.2","description":"","main":"./build/index.js","types":"./build/index.d.ts","files":["build/**/*"],"scripts":{"clean":"del-cli build","build":"npm run clean && tsc","pub":"git add . && git commit -m \"Updates\" && npm version patch && npm run build && npm publish --access public"},"keywords":[],"author":"","license":"ISC","devDependencies":{"del-cli":"^5.1.0","typescript":"^5.6.2"},"dependencies":{"@types/cookie-session":"^2.0.49","@types/jsonwebtoken":"^9.0.10","cookie-session":"^2.1.1","express":"^5.2.1","express-validator":"^7.3.2","jsonwebtoken":"^9.0.3"}}
1
+ {
2
+ "name": "@vrkktickets/common",
3
+ "version": "1.0.3",
4
+ "description": "",
5
+ "main": "./build/index.js",
6
+ "types": "./build/index.d.ts",
7
+ "files": [
8
+ "build/**/*"
9
+ ],
10
+ "scripts": {
11
+ "clean": "del-cli build",
12
+ "build": "npm run clean && tsc",
13
+ "pub": "git add . && git commit -m \"Updates\" && npm version patch && npm run build && npm publish --access public"
14
+ },
15
+ "keywords": [],
16
+ "author": "",
17
+ "license": "ISC",
18
+ "devDependencies": {
19
+ "del-cli": "^5.1.0",
20
+ "typescript": "^5.6.2"
21
+ },
22
+ "dependencies": {
23
+ "@types/cookie-session": "^2.0.49",
24
+ "@types/jsonwebtoken": "^9.0.10",
25
+ "cookie-session": "^2.1.1",
26
+ "express": "^5.2.1",
27
+ "express-validator": "^7.3.2",
28
+ "jsonwebtoken": "^9.0.3"
29
+ }
30
+ }
File without changes
File without changes
File without changes