co-body
Parse request bodies with generators inspired by Raynos/body.
Installation
$ npm install co-body
Options
Available via raw-body:
limit
number or string representing the request size limit (1mb for json and 56kb for form-urlencoded)
Available via qs:
depth
number representing the parsed object maximum hierarchy depth, default5
delimiter
string or regex representing the query string delimeter, default&
arrayLimit
nubmer representing the maximum array size or -1 to disable arrays, default20
Example
// application/jsonvar body = parse; // explicit limitvar body = parse; // application/x-www-form-urlencodedvar body = parseformreq; // eithervar body = ;
Koa
This lib also supports ctx.req
in Koa (or other libraries),
so that you may simply use this
instead of this.req
.
// application/jsonvar body = parse; // application/x-www-form-urlencodedvar body = parseformthis; // eithervar body = ;
License
MIT