Misc refactoring
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by visionmedia · committed by visionmedia · parent 6805e4f · Browse files · 1 file·+16 added−16 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+16 added−16 removed
- other:+16 added−16 removed
Provenance
- Commit
ebcdec0- Tree
d81fa8e- Author
visionmedia <tj@vision-media.ca>- Committer
visionmedia <tj@vision-media.ca>- Parent
6805e4f
1 file changed+16 added−16 removed
modified:lib/express/dsl.js+16 added-16 removed
17 unmodified lines1819202122222324252611 unmodified lines38394041424344454642434445464748495027 unmodified lines787980818282838485868788899091919293949510 unmodified lines10610710810911011011111211311411511611711511611711811912011912012112212312312412512612712812913013113213313317 unmodified linesfunction route(method) { return function(path, options, fn){ if (options instanceof Function) fn = options, options = {} if (path.indexOf('http://') === 0) if (path.startsWith('http://')) return http[method].apply(this, arguments) else if (!Express.server.running) Express.routes.push(new Route(method, path, fn, options)) else11 unmodified lines * @api public */
exports.set = function(option, val) { return val === undefined ? Express.settings[option] instanceof Function ? Express.settings[option]() : Express.settings[option] : Express.settings[option] = val return val === undefined ? Express.settings[option] instanceof Function ? Express.settings[option]() : Express.settings[option] : Express.settings[option] = val}
/** * Enable _options_.27 unmodified lines * @api public */
exports.run = function() { configure(Express.environment = process.ENV.EXPRESS_ENV || 'development') configure(Express.environment = process.env.EXPRESS_ENV || 'development') Express.plugins.each(function(plugin){ if ('init' in plugin.klass) plugin.klass.init(plugin.options) }) Express.server.run.apply(Express.server, arguments)}
/** * Configure _environment_ with _fn_. * Configure _env_ with _fn_. * * Global configuration, disregards which * environment is active: *10 unmodified lines * Running configurations: * * configure('development') * * @param {string, function} environment * @param {string, function} env * @param {function} fn * @api public */
exports.configure = function(environment, fn) { if (environment instanceof Function) fn = environment, environment = 'all'exports.configure = function(env, fn) { if (env instanceof Function) fn = env, env = 'all' if (fn instanceof Function) return Express.config.push([environment, fn]) if (typeof environment != 'string') return Express.config.push([env, fn]) if (typeof env !== 'string') throw new Error('environment required') for (var i = 0, len = Express.config.length; i < len; ++i) if (Express.config[i][0] == environment || if (Express.config[i][0] == env || Express.config[i][0] == 'all') Express.config[i][1].call(Express)}
// --- Routing API
exports.get = exports.view = route('get')exports.post = exports.create = route('post')exports.del = exports.destroy = route('delete')exports.put = exports.update = route('put')No newline at end of fileexports.put = exports.update = route('put')