THIS MODULE IS NO LONGER MAINTAINED. Please use @ozylog/http-errors instead.
Create HTTP error objects
npm install ozylog-http-errors --save
- BadRequestError([message = 'Bad Request'])
- ForbiddenError([message = 'Forbidden'])
- InternalServerError([message = 'Internal Server Error'])
- NotAcceptableError([message = 'Not Acceptable'])
- NotFoundError([message = 'Not Found'])
- NotImplementedError([message = 'Not Implemented'])
- UnauthorizedError([message = 'Unauthorized'])
- CreateError([message], [responseCode])
import {BadRequestError} from 'ozylog-http-errors';
export function validate(req, res, next) {
if (!req.body.name) return next(new BadRequestError());
}
MIT