api-error-handler
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/api-error-handler package

1.0.0 • Public • Published

api-error-handler

NPM version Build status Test coverage Dependency Status License Downloads Gittip

An error handler for JSON APIs, meant to be used with http-errors-style errors.

Example

var errorHandler = require('api-error-handler');
 
var api = new express.Router();
api.get('/users/:userid', function (req, res, next) {
 
});
 
api.use(errorHandler());
 
app.use('/api', api);

API

.use(errorHandler([options]))

Currently no options.

Errors

4xx errors are exposed to the client. Properties exposed are:

  • message
  • type
  • name
  • code
  • status

5xx errors are not exposed to the client. Instead, they are given a generic message as well as the type.

Package Sidebar

Install

npm i api-error-handler

Weekly Downloads

975

Version

1.0.0

License

MIT

Last publish

Collaborators

  • jongleberry