以下摘自 express 3.0 的 文档
app.configure([env], callback)
Conditionally invoke callback when env matches app.get(‘env’), aka process.env.NODE_ENV. This method remains for legacy reason, and is effectively an if statement as illustrated in the following snippets. These functions are not required in order to use app.set() and other configuration methods.
里面说 app.configure 是以前的版本遗留下来的,完全可以用条件判断语法取代。
文档里还举例说明了:
app.configure(function() {
app.set('title', 'My Application');
});
和
app.set('title', 'My Application');
是等价的,都是对所有环境有效。而
app.configure('development', function(){
app.set('db uri', 'localhost/dev');
})
和
if ('development' == app.get('env')) {
app.set('db uri', 'localhost/dev');
}
是一个效果。