http-errors
Create HTTP error objects
Installation
npm install @ozylog/http-errors --save
List of errors
new BadRequestError([message = 'Bad Request'])
new ForbiddenError([message = 'Forbidden'])
new InternalServerError([message = 'Internal Server Error'])
new NotAcceptableError([message = 'Not Acceptable'])
new NotFoundError([message = 'Not Found'])
new NotImplementedError([message = 'Not Implemented'])
new UnauthorizedError([message = 'Unauthorized'])
new CreateError([message], [statusCode])
Usage Example
import {BadRequestError} from '@ozylog/http-errors';
export function validate(req, res, next) {
if (!req.body.name) return next(new BadRequestError());
}
License
MIT