node-env-switcher
v0.3.3
Published
Switch env per request
Downloads
2
Readme
node-env-switcher
Switch env per request.
Usage
Express 4.0
var express = require('express');
var cookieParser = require('cookie-parser');
var switcher = require('node-env-switcher').express;
app = express();
app.use(cookieParser());
// Switch by cookie
app.use(switcher('name', type: 'cookie'));
// Switch by query
app.use(switcher('name', type: 'query'));
Koa
var koa = require('koa');
var switcher = require('node-env-switcher').koa;
app = koa();
// Switch by cookie
app.use(switcher('name', type: 'cookie'));
// Switch by query
app.use(switcher('name', type: 'query'));
Options
Secure
Encrypt the value.
switcher = require('node-env-switcher').koa;
switcher('name', secure: true, password: 'foo', type: 'cookie');
Execute node-env-switcher <string_to_encrypt> <password>
to get the encrypted value.
Custom env
The default env to switch is NODE_DEBUG
.
Switch env such as DEBUG for debug.
switcher = require('node-env-switcher').koa;
switcher('name', env: 'DEBUG');
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Copyright
Copyright (c) 2014 Daisuke Taniwaki. See LICENSE for details.