Socket
Socket
Sign inDemoInstall

koa-formidable

Package Overview
Dependencies
1
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    koa-formidable

Formidable middleware for Koa


Version published
Weekly downloads
262
decreased by-34.66%
Maintainers
1
Install size
88.8 kB
Created
Weekly downloads
 

Readme

Source

koa-formidable

Formidable middleware for Koa

![NPM][npm] ![Dependency Status][dependencies]

Breaking Change in 1.0.0: both body and files are now added to Koa's .request instead of modifying the http request (.req) directly.

API

var formidable = require('koa-formidable')

formidable(opts)

Returns the formidable middleware that parses the incoming request and adds the .request.body and .request.files to the context.

Arguments:

  • opts - the options that get passed to the Formidable.IncomingForm (you could also provide an instance of IncomingForm directly)

Example:

var formidable = require('koa-formidable')
app.use(formidable())

formidable.parse(opts, ctx)

Parse the incoming request manually.

Arguments:

  • opts - the options that get passed to the Formidable.IncomingForm (you could also provide an instance of IncomingForm directly)
  • ctx - the Koa context

Example:

var formidable = require('koa-formidable')
app.use(function*(next) {
  var form = yield formidable.parse(this)
  ...
  yield next
})

Using formidable Events

Example:

var form = new require('formidable').IncomingForm()
form.on('progress', function(bytesReceived, bytesExpected) {
      console.log(bytesReceived, bytesExpected)
})
var result = yield formidable.parse(form, this)

License

MIT

Keywords

FAQs

Last updated on 29 Apr 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc