Featured
Feature Flags
An express.js module for setting feature flags that turn on/off depending on environment and session.
Setup
There are 3 steps:
-
Install it
npm install featured
-
Configure it
featured = require('featured');
featured.configure({
});
-
Add it to express middleware
app = express.createServer();
app.configure(function(){
[...]
app.use(express.session);
app.use(featured.init);
[...]
});
Usage
Flags makes itself available in 3 places:
-
In express middleware
app.get('/betterStuff', function(req, res, next){
if(req.__featured('betterStuff'))
res.send(true);
else
res.send(false);
});
-
In express templates (jade in this example)
p Stuff
if __featured('betterStuff')
p Better Stuff
-
In express templates statically generated, for use in javascript
In template:
#{__featuredStatic}
script(src='/js/script.js')
In js/script.js:
if(__featured('betterStuff')){
alert('Better Stuff!')
}