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

express-channels

v0.6.3

Published

Application channels in a single build via middleware

Readme

express-channels

Gives application release channel functionality, without a separate build. Can serve different static content as well as different API routes on a per-user basis.

What good are application release channels?

Release channels can be a powerful way to get your software in the hands of select users to collect early feedback, find bugs, etc before release to the general public. Can be configured to serve a different channel based on different environments, automatically hiding in-progress features without having to hold off on code changes.

Install

$ npm install express-channels

Environment-based Channel Selection Example

var express = require('express'); 
var app = express();
var expressChannels = require('express-channels');

var environment = process.env.ENVIRONMENT; // 'alpha', 'beta', or 'production'

/* Configure express-channels with all available channels and set the active one */

var xc = expressChannels({
  channels: ['alpha', 'beta'], // List of channels available
  set: environment !== 'production' ? environment : null
});

/* 2: Use express-channels */

app.use(xc);

/* 3: Register channel-specific content (see below for usage details) */

app.use(expressChannels.stack(...));
app.use(expressChannels.router(...));

User-based Channel Selection Example

var express = require('express');
var app = express(); 
var expressChannels = require('express-channels');

/* 1: Configure express-channels with all available channels and selection */

var xc = expressChannels({
  channels: ['alpha', 'beta'], // List of channels available
  set: function (req) {
    var channelSelection;

    // Check for your user and preferences
    if (req.user) {
      channelSelection = req.user.channel;
    }

    return channelSelection; // If undefined, no channel-specific content will be used
  }
});

/* 2: Load your user object with channel preferences using Passport, etc */

app.use(function (req, res, next) {
  req.user = { name: 'Sally', channel: 'alpha' };
});

/* 3: Use the expressChannels middleware */

app.use(xc);

/* 4: Register channel-specific content (see below for usage details) */

app.use(expressChannels.stack(...));
app.use(expressChannels.router(...));

API

expressChannels(options)

Create a new expressChannels instance with the defined options for available channels.

require('express-channels')({
  channels: ['alpha', 'beta'],
  set: 'alpha'
});

Options

channels (Required) - String[] - Define the list of available channels in preferential order of their use. See cascade setting.

set (Required) - String OR Function - If a string is used, the given channel will be used for all requests (useful for environment-based channel-switching with no option to override). If a function is used, that function will be called with the request object and should return the name of the channel to be used (or a promise which resolves to the same).

expressChannels.router(original, channelContent, options)

Use ONE of the provided middleware/routers based upon channel preferences. Helpful to fully replace the original middleware/router with channel content in a mututally-exclusive way. That is, if the user is subscribed to channel-specific content, the original content will be unavailable. This can be used, for example, to version a particular route.

app.use(xc.router(require('./user-router'), {
  alpha: require('./user-router.alpha'),
  beta: require('./user-router.beta')
}));

original (required)

The original non-channel-specific router/middleware to use if no channel-specific content is used.

channelContent (required)

The channel content hash where the keys are channel names and the values are anything that can be passed to express' app.use (e.g. middleware, routers).

options (optional)

cascade - Boolean - Defaults to true - When enabled, channels which follow the set channel in the channels list will be used when the set channel is missing or does not serve a response. When disabled, will prevent the system from ever serving channel content from another channel than the one currently set.

For example a router with A and C provided: if the set channel is B and cascade is false, no channel-specific content will be used. If cascade is true, the user's preference is still B, but because B is not available, C (coming after B in the channel list) will be used instead.

expressChannels.stack(channelConent)

Use ANY of the provided middleware/routers in channel order, starting with set channel and progressing down the list of configured channels. This is particularly useful for serving static content resources, allowing for channel-specific content to be available, but original assets remain accessible.

var xc = expressChannels({
  channels: ['alpha', 'beta'], // List of channels available
  set: 'alpha'
});

app.use(xc.stack({
  alpha: express.static('./static/_alpha'), // Available only to alpha subscribers
  beta: express.static('./static/_beta') // Available to alpha OR beta subscribers
}));
app.use(express.static('./static')); // Available to everyone

####channelContent

The channel content hash where the keys are channel names and the values are anything that can be passed to express' app.use (e.g. middleware, routers).

License

MIT