|
5 years ago | |
---|---|---|
.. | ||
examples | 5 years ago | |
test | 5 years ago | |
.editorconfig | 5 years ago | |
.gitattributes | 5 years ago | |
.jshintrc | 5 years ago | |
.npmignore | 5 years ago | |
.travis.yml | 5 years ago | |
history.md | 5 years ago | |
index.js | 5 years ago | |
license.md | 5 years ago | |
package.json | 5 years ago | |
readme.md | 5 years ago |
A koa body parser middleware with support for
multipart
,json
orurlencoded
request bodies. Via formidable and co-body.
Install with npm
$ npm install koa-better-body
For a more comprehensive examples, see examples folder.
examples/multer
- usage like Express's bodyParser - multer npm run examples-multer
examples/koa-router
- usage with Alex's koa-router npm run examples-koa-router
However,
koa-better-body
have few custom options, see also co-body, raw-body, formidable
patchNode
{Boolean} Patch request body to Node's ctx.req
object, default false
patchKoa
{Boolean} Patch request body to Koa's ctx.request
object, default true
jsonLimit
{String|Number} The byte limit of the JSON body, default 1mb
formLimit
{String|Number} The byte limit of the form body, default 56kb
encoding
{String} Sets encoding for incoming form fields, default utf-8
multipart
{Boolean} Support multipart/form-data
request bodies, default false
formidable
{Object} Options that are passing to formidable
formidable.maxFields
{Number} See formidable-options. our default 10
formidable.multiples
{Boolean} See formidable-options, our default true
formidable.keepExtensions
{Boolean} See formidable-options, our default true
return
{GeneratorFunction} That you can use with koa or coSee node-formidable for a full list of options
bytesExpected
{Integer} The expected number of bytes in this form, default null
maxFields
{Integer} Limits the number of fields that the querystring parser will decode, default 1000
maxFieldsSize
{Integer} Limits the amount of memory a field can allocate in bytes, default 2mb
uploadDir
{String} Sets the directory for placing file uploads in, default os.tmpDir()
hash
{String} If you want checksums calculated for incoming files - 'sha1'
or 'md5'
, default false
multiples
{Boolean} Multiple file uploads or no, default false
As usual -
npm test
or if you have mocha globally -mocha --harmony-generators
.
$ npm test
Charlike Mike Reagent
Daryl Lau
Copyright (c) 2014 Charlike Mike Reagent, Daryl Lau, contributors.
Released under the MIT
license.