co-body-bigint

3.0.0 • Public • Published

co-body

NPM version build status Test coverage David deps npm download

Parse request bodies with generators inspired by Raynos/body.

Installation

$ npm install co-body

Options

  • limit number or string representing the request size limit (1mb for json and 56kb for form-urlencoded)
  • 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 object).
  • queryString an object of options when parsing query strings and form data. See qs for more information.

more options available via raw-body:

Example

// application/json
var body = yield parse.json(req);
 
// explicit limit
var body = yield parse.json(req, { limit: '10kb' });
 
// application/x-www-form-urlencoded
var body = yield parse.form(req);
 
// text/plain
var body = yield parse.text(req);
 
// either
var body = yield parse(req);

Koa

This lib also supports ctx.req in Koa (or other libraries), so that you may simply use this instead of this.req.

// application/json
var body = yield parse.json(this);
 
// application/x-www-form-urlencoded
var body = yield parse.form(this);
 
// text/plain
var body = yield parse.text(this);
 
// either
var body = yield parse(this);

License

MIT

/co-body-bigint/

    Package Sidebar

    Install

    npm i co-body-bigint

    Weekly Downloads

    1

    Version

    3.0.0

    License

    MIT

    Last publish

    Collaborators

    • fiolkaf