@octoris/body-parser
v0.1.2
Published
A body parser middleware for octoris
Downloads
28
Maintainers
Readme
body-parser
A body parser middleware for octoris
Install
npm i @octoris/body-parser
json(opts)
The json parser for handling json payloads
Options
strict
: when set to true, JSON parser will only accept arrays and objects; when false will accept anything JSON.parse accepts. Defaults to true. (also strict mode will always return an object)limit
: Number or string representing the request size limit. Defaults to1mb
encoding
: The content encoding type. Defaults toutf8
Usage
const { router, response, methods} = require('octoris')
const { json } = require('@octoris/body-parser')
function handler () {
return new Promise(resolve => send(200, 'Okay!'))
}
const home = router.route([router.fixed('/')], [methods.GET(handler)])
router.composeRoutes({}, [home], [json()])
form(opts)
Form parser for handling url-encoded form payloads
Options
queryString
: An options object that is passed directly to the qs modulelimit
: A number or string representing the request size limit. Defaults to56kb
qs
: The querystring function you'd like to use. Defaults toqs
encoding
: The content encoding type. Defaults toutf8
Usage
const { router, response, methods} = require('octoris')
const { form } = require('@octoris/body-parser')
function handler () {
return new Promise(resolve => send(200, 'Okay!'))
}
const home = router.route([router.fixed('/')], [methods.GET(handler)])
router.composeRoutes({}, [home], [form()])