npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

busser

v1.2.0

Published

An Express Wrapper for Busboy

Readme

Busser

Busser is a node.js middleware for handling multipart/form-data, which is primarily used for uploading files. It is written on top of busboy for maximum efficiency and is an alternative to multer.

NOTE: Busser should only be used on multipart forms, use bodyParser for other types of forms.

Installation

$ npm install --save busser

Usage

Currently, Busser only works with a single file, adding the property file to the request object. The file property contains the following fields:

{
    'original': 'upload.ext',//the name of the uploaded file
    'name': 'file.ext',//the name underwhich the file is stored
    'dest': './path/to/dir/',//the directory where the file is stored
    'path': 'full/path/to/file/file.ext'//the full path to the file
}

This information given so that you can update references or store the file location in a database. The actual file storage is handled by the middleware.

It is possible to use Busser with the given default settings:

{
    filter: defaultFilter,//allows all files
    name: defaultName,//generates a new unique name for the file, preserving extension
    dest: defaultDest,//returns the location './uploads/'
    fieldname: 'file',//the fieldname to look for in the form
    sizeLimit: Math.pow(2, 25),//limits files to 32mb, can easily be changed
    mimeReg: /.*/ //allows all mimetypes, currently checked by regular expression
}

A basic usage example:

var express = require('express');
var busser = require('busser');

var router = express.Router();

var handleUpload = busser({
   fieldname: 'image',//look for the field 'image'
   sizeLimit: Math.pow(2, 20),//limit to 1mb
   mimeReg: busser.regex.image//limit to images
});

router.post('/upload-image', handleUpload, function(req, res){
   res.jsonp({
      success: req.file.original + ' stored.'
   });
});

To handle the errors more gracefully than allowing them to be formatted by Express, call the handler yourself:

router.post('/upload-image', function(req, res, next){
    handleUpload(req, res, function(err){
        if(err){
            res.jsonp({
                error: err.message
            });
        }else{
            next();
        }
    });
}, function(req, res){
    res.jsonp({
        success: req.file.original + ' stored.'
    });
});

Options

Currently, the options available are:

Key | Type | Description --- | --- | --- fieldname | String | name of the field in the form to look for. Throws error if not found, or if a file is found under a different name mimeReg | String or RegExp | mimetype of the file. Throws error if no match is found. Some RegExp are provided on the busser.regex object sizeLimit | Number (bytes) | size of the file. Throws error if file is too big. Some size are provided on the busser.size object filter | Function(req, file, next) | filter for file. Throws error if next is not called with a truthy value dest | Function(req, file, next) | destination folder for file. Default passes './uploads/' to next name | Function(req, file, next) | name to store file as. Default passes a unique name with extension preserved to next

Which are run in this order as well (meaning failure will result first from fieldname, then mimetype, etc.).

filter, dest, and name are each passed the request object, an object describing the file, and the next function to continue execution. The file object can be described as such:

{
    'filename': 'upload.ext',//the name of the uploaded file
    'file': <ReadStream>,//the stream of the file
    'encoding': 'utf8',//the encoding of the file
    'mimetype': 'type/ext'//tye mimetype of the file
}

Provided shortcuts

busser.regex = {
    'image': /^image\// //'image/png','image/jpg', etc.
}

busser.size = {
    kb: function(n){
        return n * Math.pow(2, 10);
    },
    mb: function(n){
        return n * Math.pow(2, 20);
    },
    gb: function(n){
        return n * Math.pow(2, 30);
    }
}

Future

I did this for a school project when I had a lot of trouble getting multer to work the way I wanted it to. Hopefully I'll be able to keep updating it to support multiple files with multiple configurations. In the mean time, this should work well alongside bodyParser for single file uploads, like profile pictures or code files.