fail-express

1.0.2 • Public • Published

fail-express

npm version Build Status Coverage Status

Fail-express is an express error-handler middleware for JSON APIs. This library uses http-status.

Example

const express = require('express');
const failExpress = require('fail-express');
 
const app = new express();
const router = express().Router();
 
router.get('/status', (req, res, next) => {
  res.send('Online!');
});
 
app.use('/api/v1', router);
 
router.use(failExpress());

API

const failExpress = require('fail-express');

failExpress([options]);

Use the new fail-express middleware function using the given options.

Options

fail-express accepts this properties in the options object.

errorReporter

Function that receives the error object with its default properties. Default fail-express error reporter:

const defaultErrorReporter = error => {
  console.error(error.stack);
};
displayStackTrace

Appends the error stack trace to the error object.

exposeAdditionalProperties

Appends additional properties to the error object.

Errors

Default properties:

  • message
  • type
  • name
  • code
  • status

License

MIT

Package Sidebar

Install

npm i fail-express

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

8.22 kB

Total Files

11

Last publish

Collaborators

  • enbermudev