exploder
v1.0.0
Published
Express port of Boom
Downloads
3
Maintainers
Readme
exploder
HTTP-friendly error objects. This is a port of hapi's boom module as express middleware. It is based on express-boom.
Example
const Express = require('express');
const Exploder = require('exploder');
const app = Express();
app.use(Exploder());
app.use(function (req, res) {
res.boom.notFound(); // Responds with a 404 status code
});
API
For a complete list of methods offered by boom, see the boom documentation.
exploder
also provides the following options when setting up the middleware:
format(err)
(function) - A function that formats the boom error before replying to the client. This only applies to functions that send a response to the client (i.e. notwrap()
orcreate()
). By default, the boom error'soutput.payload
is sent as the response payload. If aformat()
function is provided, the complete boom error is passed as the only argument, and the return value is sent as the response payload.