pepkin88 / koa-better-body

A koa body parser middleware with support for `multipart`, `json`, `csp-report` or `urlencoded` request bodies. Via formidable and co-body.

Home Page:http://j.mp/1stW47C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

better-body NPM version Build Status Dependency Status Coveralls

A koa body parser middleware with support for multipart, json, csp-report or urlencoded request bodies. Via formidable and co-body.

Install Nodei.co stats

Install with npm

$ npm install koa-better-body
$ npm test

Usage

For a more comprehensive examples, see examples folder.

.koaBetterBody

However, koa-better-body have few custom options, see also co-body, raw-body, formidable

  • [options] {Object}
    • 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
    • fieldsKey {String|Boolean} Name of the key for fields in the body object or false, default 'fields'
    • formidable {Object} Options that are passing to formidable
  • return {GeneratorFunction} That you can use with koa or co

formidable options

See 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

Authors & Contributors

Charlike Make Reagent author tips

License MIT license

Copyright (c) 2014 Charlike Make Reagent, contributors.
Released under the MIT license.

About

A koa body parser middleware with support for `multipart`, `json`, `csp-report` or `urlencoded` request bodies. Via formidable and co-body.

http://j.mp/1stW47C

License:Other


Languages

Language:JavaScript 94.5%Language:Makefile 5.5%