body-parser-ext
An extended version of body-parser middleware with additional error handling using VEerror
Extended error handling
- ERR_BODY_PARSE_JSON
- ERR_PAYLOAD_TOO_LARGE
Installation
npm i -S body-parser-ext
Usage
As well as body-parser
Javascript example
'use strict'; const express = ;const bodyParser = ; const PORT = 3000;const app = ; // Parse application/jsonapp; // Sample middlewareapp; // Other middlewares // The catch 404 error handlerapp; // The 'catch-all' error handlerapp; // Start serverapp;
Typescript example
;; ;; // Parse application/jsonapp.usebodyParser.json; // Sample middlewareapp.get'/',; // Other middlewares // The catch 404 error handlerapp.use; // The 'catch-all' error handlerapp.use err: any, _: express.Request, res: express.Response, __: express.NextFunction ; // Start serverapp.listenPORT,console.log`Example app listening on port `;