pr-express-body-parser
v0.1.4
Published
Express middleware for request body parsing
Downloads
15
Maintainers
Readme
pr-express-body-parser
Express middleware for parsing different body-types
Philosophy
Parsing of all different body-types in Express under one roof
Installation
$ npm install pr-express-body-parser
APIs
The module exports express-middleware function bodyParsingMiddleware(config); the config is a JSON object with options for different body-types.
The default config-options are:
{
"json": {
"limit": "1mb",
"type": ["json", "*/json", "+json"]
},
"text": {
"limit": "1mb",
"type": ["text/*"]
},
"urlencoded": {
"limit": "1mb",
"extended": true
},
"raw": {
"limit": "1mb",
"type": "application/*"
},
"multipart": {} // use busboy defaults
}
Refer to the individual module documentation for detailed config-options:
Usage
var express = require("express").
expressBodyParser = require("pr-express-body-parser");
var app = express();
express.use(expressBodyParser());
For all body-types except multipart, the request-body data is available in req.body property. In case of multiparty data, it is available via req.busboy as Busboy events and related streams.
Refer to test server.js implementation for usage details.
NOTE: In case of multipart, the request-body is piped to req.busboy by default
Test
$ npm install # inside pr-express-body-parser
$ npm test