1.0.2 • Published 4 years ago

fail-express v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

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

1.0.2

4 years ago

1.0.1

5 years ago

1.0.0-rc.1

5 years ago

1.0.0

5 years ago