Skip to content
This repository was archived by the owner on Jul 12, 2019. It is now read-only.

ozylog/http-errors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

http-errors

Create HTTP error objects

Travis npm

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

About

HTTP errors

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published