Adds environment-specific hooks to express apps
npm install --save expressive
var expressive = require'expressive';var express = require'express';var app = express;expressiveapp;appuse'/normal-route'next;;appdevelopmentget'/dev-only-route'next;;
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.
expressiveapp 'development' 'test';
You can specify the following options to change the default behavior:
The aforementioned list of environments
// "envs" can also be a string hereexpressiveapp envs: 'development' 'test' ;
The current environment. Defaults to
expressiveapp env: nconfget'NODE_ENV' ;
Additionally, you can pass this env as a third parameter, which can help keep the syntax short.
expressiveapp 'development' nconfget'NODE_ENV';
app.development.use seems long, you can provide environment aliases to shorten it.
expressiveapp alias: development: 'dev' ;
Then you can just use