Payload / body parser (including multipart payloads) middleware.
This is a middleware wrapper for the subtext payload parser, originally written by Eran Hammer for hapijs
##Example:
const express = require('express')
const subtext = require('subtext-middleware')
const app = express()
app.use(subtext())
app.use(function (req, res) {
res.setHeader('Content-Type', 'text/plain')
res.write('you posted:\n')
res.end(JSON.stringify(req.body, null, 2))
})
API Reference:
Returns a middleware that parses a request body and exposes it via req.body
options
are the following:
parse
: boolean, defaults totrue
output
: string of the following: 'data', 'stream', 'file'. Defaults todata
maxBytes
: intoverride
: stringdefaultContentType
: stringallow
: string, only allow a certain media typetimeout
: integer, limit time spent buffering requestqs
: object, to pass into the qs moduleuploads
: string, directory for file uploadsdecoders
: an object mapping content-encoding names to their corresponding decoder functionscompression
: an object mapping content-encoding names to their corresponding options passed to thedecoders
functions