我正在使用node.js + express.js + everyauth.js。我已将所有 everyauth 逻辑移至模块文件中
var login = require('./lib/everyauthLogin');
在其中,我使用密钥/秘密组合加载我的 oAuth 配置文件:
var conf = require('./conf');
.....
twitter: {
consumerKey: 'ABC',
consumerSecret: '123'
}
这些代码对于不同的环境(开发/暂存/生产)是不同的,因为回调是针对不同的 url。
问题:如何在环境配置中设置这些以过滤所有模块,或者我可以将路径直接传递到模块中吗?
在环境中设置:
app.configure('development', function(){
app.set('configPath', './confLocal');
});
app.configure('production', function(){
app.set('configPath', './confProduction');
});
var conf = require(app.get('configPath'));
Pass in
app.configure('production', function(){
var login = require('./lib/everyauthLogin', {configPath: './confProduction'});
});
?希望这是有道理的