node package manager
Painless code sharing. npm Orgs help your team discover, share, and reuse code. Create a free org »


Build Status downloads npm Code Climate Test Coverage dependencies

NPM info



npm install --save expressive


var express = require('express');
var app = express();
var expressive = require('expressive');
// nconf setup not pictured 
expressive(app, nconf.get('NODE_ENV')).env('development');
app.use('/normal-route', function(req, res, next) {
app.development.get('/dev-only-route', function(req, res, next) {

Expressive installs environment-specific hooks in your express app, which essentially eliminates the need to do something like

if (process.env.NODE_ENV === 'development') {
  app.use(/* some dev route */)

Of course, you could just use if statements like this, but I've found that expressive makes an app easier to read because all the route definitions are parallel. Additionally, testing is slightly easier because you don't have to specify a describe for each environment. You can just assert that app.environmentName exists and, if you're into this kind of thing, that it gets called with the appropriate routes and handlers.


Expressive exports a single function that takes two arguments: your express app and, optionally, the current environment (defaulting to process.env.NODE_ENV). It returns an object with a single method: .env.



expressive(app, currentEnvironment)


The .env method also takes two arguments: the name of the environment to add hooks for and an optional alias for that environment. This method returns the same object (this) so you can chain your .env calls.


var express = require('express');
var app = express();
var expressive = require('expressive');
  .env('development', 'dev') // Alias "dev" allows you to do instead of app.development.use


Please see the contribution guidelines.