Package Exports
- body-parser-ext
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (body-parser-ext) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
body-parser-ext
An extended version of body-parser middleware with JSON error parse handling using VEerror.
Installation
npm i -S body-parser-extUsage
As well as body-parser.
const express = require('express');
const bodyParser = require('body-parser-ext');
const app = express();
// Parse application/json
app.use(bodyParser.json());
// ... Other middlewares
// The catch 404 error handler
app.use((req, res) => {
res.status(404).end();
});
// The 'catch-all' error handler
app.use((err, req, res, next) => {
// Bad Request
if (err.name === 'BodyParseJsonError') {
return res.status(400).end();
}
// Unexpected error
res.status(500).end();
});