koa-parse-json
Parse json request body, generator style.
It seems that similar modules don't provide sane stack traces, or simply ignore errors. Because this one is completly generator-based, it provides proper stacktraces on parse error.
Install
$ npm install koa-parse-json
Usage
var koa = ;var body = ; var app = ; app; app;
API
body(opts)
Returns a koa middleware, that can parse JSON request body.
It stops reading after opts.limit
bytes, and throws 413,
if Content-Length
doesn't match with request length, 400 is throwed.
Default opts.limit
is 1MB.
License
MIT