remove app.configure()
Esse commit está contido em:
@@ -334,60 +334,6 @@ app.disable = function(setting){
|
||||
return this.set(setting, false);
|
||||
};
|
||||
|
||||
/**
|
||||
* Configure callback for zero or more envs,
|
||||
* when no `env` is specified that callback will
|
||||
* be invoked for all environments. Any combination
|
||||
* can be used multiple times, in any order desired.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* app.configure(function(){
|
||||
* // executed for all envs
|
||||
* });
|
||||
*
|
||||
* app.configure('stage', function(){
|
||||
* // executed staging env
|
||||
* });
|
||||
*
|
||||
* app.configure('stage', 'production', function(){
|
||||
* // executed for stage and production
|
||||
* });
|
||||
*
|
||||
* Note:
|
||||
*
|
||||
* These callbacks are invoked immediately, and
|
||||
* are effectively sugar for the following:
|
||||
*
|
||||
* var env = process.env.NODE_ENV || 'development';
|
||||
*
|
||||
* switch (env) {
|
||||
* case 'development':
|
||||
* ...
|
||||
* break;
|
||||
* case 'stage':
|
||||
* ...
|
||||
* break;
|
||||
* case 'production':
|
||||
* ...
|
||||
* break;
|
||||
* }
|
||||
*
|
||||
* @param {String} env...
|
||||
* @param {Function} fn
|
||||
* @return {app} for chaining
|
||||
* @api public
|
||||
*/
|
||||
|
||||
app.configure = function(env, fn){
|
||||
var envs = 'all'
|
||||
, args = [].slice.call(arguments);
|
||||
fn = args.pop();
|
||||
if (args.length) envs = args;
|
||||
if ('all' == envs || ~envs.indexOf(this.settings.env)) fn.call(this);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* Delegate `.VERB(...)` calls to `router.VERB(...)`.
|
||||
*/
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
|
||||
var express = require('../');
|
||||
|
||||
describe('config', function(){
|
||||
describe('.configure()', function(){
|
||||
describe('when no env is given', function(){
|
||||
it('should always execute', function(){
|
||||
var app = express();
|
||||
var calls = [];
|
||||
|
||||
app.configure(function(){
|
||||
calls.push('all');
|
||||
});
|
||||
|
||||
app.configure('test', function(){
|
||||
calls.push('test');
|
||||
});
|
||||
|
||||
app.configure('test', function(){
|
||||
calls.push('test 2');
|
||||
});
|
||||
|
||||
calls.should.eql(['all', 'test', 'test 2'])
|
||||
})
|
||||
})
|
||||
|
||||
describe('when an env is given', function(){
|
||||
it('should only execute the matching env', function(){
|
||||
var app = express();
|
||||
var calls = [];
|
||||
|
||||
app.set('env', 'development');
|
||||
|
||||
app.configure('development', function(){
|
||||
calls.push('dev');
|
||||
});
|
||||
|
||||
app.configure('test', function(){
|
||||
calls.push('test');
|
||||
});
|
||||
|
||||
calls.should.eql(['dev']);
|
||||
})
|
||||
})
|
||||
|
||||
describe('when several envs are given', function(){
|
||||
it('should execute when matching one', function(){
|
||||
var app = express();
|
||||
var calls = [];
|
||||
|
||||
app.set('env', 'development');
|
||||
|
||||
app.configure('development', function(){
|
||||
calls.push('dev');
|
||||
});
|
||||
|
||||
app.configure('test', 'development', function(){
|
||||
calls.push('dev 2');
|
||||
});
|
||||
|
||||
app.configure('development', 'test', function(){
|
||||
calls.push('dev 3');
|
||||
});
|
||||
|
||||
app.configure('test', function(){
|
||||
calls.push('dev 3');
|
||||
});
|
||||
|
||||
calls.should.eql(['dev', 'dev 2', 'dev 3']);
|
||||
})
|
||||
})
|
||||
|
||||
it('should execute in order as defined', function(){
|
||||
var app = express();
|
||||
var calls = [];
|
||||
|
||||
app.configure(function(){
|
||||
calls.push('all');
|
||||
});
|
||||
|
||||
app.configure('test', function(){
|
||||
calls.push('test');
|
||||
});
|
||||
|
||||
app.configure(function(){
|
||||
calls.push('all 2');
|
||||
});
|
||||
|
||||
app.configure('test', function(){
|
||||
calls.push('test 2');
|
||||
});
|
||||
|
||||
calls.should.eql(['all', 'test', 'all 2', 'test 2'])
|
||||
})
|
||||
})
|
||||
})
|
||||
Referência em uma Nova Issue
Bloquear um usuário