@sima-board/common
Advanced tools
Comparing version 1.0.3 to 1.0.5
@@ -1,3 +0,3 @@ | ||
import CustomError from './CustomError'; | ||
declare class BadRequestError extends CustomError { | ||
import { CustomError } from "./CustomError"; | ||
export declare class BadRequestError extends CustomError { | ||
message: string; | ||
@@ -10,2 +10,1 @@ statusCode: number; | ||
} | ||
export default BadRequestError; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const CustomError_1 = __importDefault(require("./CustomError")); | ||
class BadRequestError extends CustomError_1.default { | ||
exports.BadRequestError = void 0; | ||
const CustomError_1 = require("./CustomError"); | ||
class BadRequestError extends CustomError_1.CustomError { | ||
constructor(message) { | ||
@@ -18,2 +16,2 @@ super(message); | ||
} | ||
exports.default = BadRequestError; | ||
exports.BadRequestError = BadRequestError; |
@@ -1,2 +0,2 @@ | ||
declare abstract class CustomError extends Error { | ||
export declare abstract class CustomError extends Error { | ||
abstract statusCode: number; | ||
@@ -9,2 +9,1 @@ constructor(message: string); | ||
} | ||
export default CustomError; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CustomError = void 0; | ||
class CustomError extends Error { | ||
@@ -9,2 +10,2 @@ constructor(message) { | ||
} | ||
exports.default = CustomError; | ||
exports.CustomError = CustomError; |
@@ -1,3 +0,3 @@ | ||
import CustomError from "./CustomError"; | ||
declare class DatabaseConnectionError extends CustomError { | ||
import { CustomError } from "./CustomError"; | ||
export declare class DatabaseConnectionError extends CustomError { | ||
statusCode: number; | ||
@@ -10,2 +10,1 @@ reason: string; | ||
} | ||
export default DatabaseConnectionError; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const CustomError_1 = __importDefault(require("./CustomError")); | ||
class DatabaseConnectionError extends CustomError_1.default { | ||
exports.DatabaseConnectionError = void 0; | ||
const CustomError_1 = require("./CustomError"); | ||
class DatabaseConnectionError extends CustomError_1.CustomError { | ||
constructor() { | ||
@@ -18,2 +16,2 @@ super("Error connecting to db"); | ||
} | ||
exports.default = DatabaseConnectionError; | ||
exports.DatabaseConnectionError = DatabaseConnectionError; |
@@ -1,2 +0,2 @@ | ||
import CustomError from './CustomError'; | ||
import { CustomError } from "./CustomError"; | ||
export declare class NotAuthorizedError extends CustomError { | ||
@@ -3,0 +3,0 @@ statusCode: number; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NotAuthorizedError = void 0; | ||
const CustomError_1 = __importDefault(require("./CustomError")); | ||
class NotAuthorizedError extends CustomError_1.default { | ||
const CustomError_1 = require("./CustomError"); | ||
class NotAuthorizedError extends CustomError_1.CustomError { | ||
constructor() { | ||
super('Not Authorized'); | ||
super("Not Authorized"); | ||
this.statusCode = 401; | ||
@@ -15,5 +12,5 @@ Object.setPrototypeOf(this, NotAuthorizedError.prototype); | ||
serializeErrors() { | ||
return [{ message: 'Not authorized' }]; | ||
return [{ message: "Not authorized" }]; | ||
} | ||
} | ||
exports.NotAuthorizedError = NotAuthorizedError; |
@@ -1,2 +0,2 @@ | ||
import CustomError from './CustomError'; | ||
import { CustomError } from "./CustomError"; | ||
export declare class NotFoundError extends CustomError { | ||
@@ -3,0 +3,0 @@ statusCode: number; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NotFoundError = void 0; | ||
const CustomError_1 = __importDefault(require("./CustomError")); | ||
class NotFoundError extends CustomError_1.default { | ||
const CustomError_1 = require("./CustomError"); | ||
class NotFoundError extends CustomError_1.CustomError { | ||
constructor() { | ||
super('Route not found'); | ||
super("Route not found"); | ||
this.statusCode = 404; | ||
@@ -15,5 +12,5 @@ Object.setPrototypeOf(this, NotFoundError.prototype); | ||
serializeErrors() { | ||
return [{ message: 'Not Found' }]; | ||
return [{ message: "Not Found" }]; | ||
} | ||
} | ||
exports.NotFoundError = NotFoundError; |
@@ -1,4 +0,4 @@ | ||
import { ValidationError } from 'express-validator'; | ||
import CustomError from './CustomError'; | ||
declare class RequestValidationError extends CustomError { | ||
import { ValidationError } from "express-validator"; | ||
import { CustomError } from "./CustomError"; | ||
export declare class RequestValidationError extends CustomError { | ||
errors: ValidationError[]; | ||
@@ -15,2 +15,1 @@ statusCode: number; | ||
} | ||
export default RequestValidationError; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const CustomError_1 = __importDefault(require("./CustomError")); | ||
class RequestValidationError extends CustomError_1.default { | ||
exports.RequestValidationError = void 0; | ||
const CustomError_1 = require("./CustomError"); | ||
class RequestValidationError extends CustomError_1.CustomError { | ||
constructor(errors) { | ||
super('Invalid request parameters'); | ||
super("Invalid request parameters"); | ||
this.errors = errors; | ||
@@ -17,3 +15,3 @@ this.statusCode = 400; | ||
return this.errors.map((err) => { | ||
if (err.type === 'field') { | ||
if (err.type === "field") { | ||
return { message: err.msg, field: err.path }; | ||
@@ -25,2 +23,2 @@ } | ||
} | ||
exports.default = RequestValidationError; | ||
exports.RequestValidationError = RequestValidationError; |
@@ -1,3 +0,2 @@ | ||
import { Request, Response, NextFunction } from 'express'; | ||
declare const errorHandler: (err: Error, req: Request, res: Response, next: NextFunction) => Response<any, Record<string, any>> | undefined; | ||
export default errorHandler; | ||
import { Request, Response, NextFunction } from "express"; | ||
export declare const errorHandler: (err: Error, req: Request, res: Response, next: NextFunction) => Response<any, Record<string, any>> | undefined; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const CustomError_1 = __importDefault(require("../errors/CustomError")); | ||
exports.errorHandler = void 0; | ||
const CustomError_1 = require("../errors/CustomError"); | ||
const errorHandler = (err, req, res, next) => { | ||
if (err instanceof CustomError_1.default) { | ||
if (err instanceof CustomError_1.CustomError) { | ||
return res.status(err.statusCode).send({ errors: err.serializeErrors() }); | ||
} | ||
res.status(400).send({ | ||
errors: [{ message: 'Something went wrong' }] | ||
errors: [{ message: "Something went wrong" }], | ||
}); | ||
}; | ||
exports.default = errorHandler; | ||
exports.errorHandler = errorHandler; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validateRequest = void 0; | ||
const express_validator_1 = require("express-validator"); | ||
const RequestValidationError_1 = __importDefault(require("../errors/RequestValidationError")); | ||
const RequestValidationError_1 = require("../errors/RequestValidationError"); | ||
const validateRequest = (req, res, next) => { | ||
const errors = (0, express_validator_1.validationResult)(req); | ||
if (!errors.isEmpty()) { | ||
throw new RequestValidationError_1.default(errors.array()); | ||
throw new RequestValidationError_1.RequestValidationError(errors.array()); | ||
} | ||
@@ -14,0 +11,0 @@ next(); |
{ | ||
"name": "@sima-board/common", | ||
"version": "1.0.3", | ||
"version": "1.0.5", | ||
"main": "./build/index.js", | ||
@@ -5,0 +5,0 @@ "types": "./build/index.d.ts", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
10244
263