Adds environment-specific hooks to express apps


npm install --save expressive

var expressive = require('expressive');
var express = require('express');
var app = express();
app.use('/normal-route', function(reqresnext) {
app.development.get('/dev-only-route', function(reqresnext) {

When you call expressive and pass in an express app, it will add environment specific hooks that you can use for specific environments only. By default, it will use ['development'] as the environment list, but you can pass an array of environments as a second argument (or a single string if you only setting up one environment), or an options object (outlined below).

This is similar to wrapping app calls in checks against the environment, but I've found that this method makes an app easier to read because all the route definitions are parallel.

expressive(app, ['development', 'test']);
expressive(app, 'development');

You can specify the following options to change the default behavior:

The aforementioned list of environments

// "envs" can also be a string here 
expressive(app, { envs: ['development', 'test'] });

The current environment. Defaults to process.env.NODE_ENV.

expressive(app, { env: nconf.get('NODE_ENV') });

Additionally, you can pass this env as a third parameter, which can help keep the syntax short.

expressive(app, 'development', nconf.get('NODE_ENV'));

If app.development.use seems long, you can provide environment aliases to shorten it.

expressive(app, { alias: { development: 'dev' } });

Then you can just use*args*/);