@nicolasparada/bodyparser-middleware
v0.5.2
Published
Body Parser Middlewares
Downloads
2
Readme
@nicolasparada/bodyparser-middleware
Body Parser Middleware.
Usage
const framework = require('@nicolasparada/web-framework')
const bodyparser = require('@nicolasparada/bodyparser-middleware')
const app = framework()
app.post('/json', bodyparser.json(), req => req.body)
app.post('/multipart', bodyparser.multipart(), req => {
// Files are at req.files
return req.body
})
app.listen(80, '127.0.0.1', () => {
console.log('Make a POST request to http://localhost/echo-body')
})
Options
JSON
limit
{number} Maximum bytes to parse. Defaults to(1024 ** 2) * 100
(1mB).types
{string[]} 'Content-Type' headers to handle. Defaults to:- application/json
- application/json-patch+json
- application/vnd.api+json
- application/csp-report
MULTIPART
The multipart body parser uses formidable, so you can pass any options supported by it.