New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

koa-simple-body

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-simple-body

A clean body parser for Koa v2

  • 1.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

koa-simple-body

npm install koa-simple-body

Coherent and consistent body parsing implementation for Koa v2.

Supports multipart, url-encoded and JSON data by default. Check the index.js for the specific MIME types.

Everything it doesn't understand is parsed as plain text.

Usage

Defaults

const Koa = require("koa")
const bodyParser = require("bodyParser")

const app = new Koa()

app.use(bodyParser())

app.use(ctx => {
  // Print fields
  console.log(ctx.request.fields)

  // Print files (formidable)
  console.log(ctx.request.files)
})

That's it!

Extra options

bodyParser({
  useBuffer: true,      // enables parsing text/* as a buffer
  buffer: "50kb",       // max buffer size
  text: "50kb",         // max text size
  json: "100kb",        // max json size
  urlEncoded: "500kb",  // max url-encoded size
  multipart: {
    // Formidable options object (some examples shown)
    maxFieldsSize: 5 * 1024 * 1024, // 5mb

    // Allow array of files with 'multiple' attribute
    multiples: true
  }    
})

For more information on the Formidable.IncomingForm options available, see the felixge/node-formidable repository.

Roadmap

2.0

  • Add support for bubbling errors to middleware (feedback and suggestions for API encouraged)
  • Ensure default size settings are coherent and best defaults

License

MIT - see LICENSE file.

FAQs

Package last updated on 07 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc