Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

then-busboy

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

then-busboy

Promise-based wrapper around Busboy, inspired by async-busboy

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
119
increased by120.37%
Maintainers
1
Weekly downloads
 
Created
Source

then-busboy

Promise-based wrapper around Busboy, inspired by async-busboy

Installation

Use can install then-pusboy from npm:

npm install then-busboy --save

Or with yarn

yarn add then-busboy
yarn

Usage

Just import then-busboy and pass request object as first argument.

For example:

var busboy = require("then-busboy");
var createServer = require("http").createServer;

function callback(req, res) {
  if (req.method === "GET") {
    res.statusCode = 404
    return res.end("Not Found");
  }

  if (req.method !== "POST") {
    res.statusCode = 405;
    return res.end("Method Not Allowed");
  }

  // Get result from then-busboy
  function onFulfilled(data) {
    res.writeHead("Content-Type", "application/json");
    res.end(JSON.stringify(data));
  }

  // Handle errors
  function onRejected(err) {
    res.statusCode = err.status || 500;
    res.end(String(err));
  }

  // Call `then-busboy` with `req`
  busboy(req).then(onFulfilled, onRejected);
}

createServer(callback)
  .listen(2319, () => console.log("Server started on http://localhost:2319"))

then-busboy always return a Promise, so you can use it with asynchronous function syntax:

// Some your awesome code with async workflow...
var data = await busboy(req);

License

MIT

Keywords

FAQs

Package last updated on 14 Oct 2016

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