Added app.listen() as a shortcut for http.createServer(app).listen()
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 7a7d77e · Browse files · 2 files·+44 added−10 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+44 added−10 removed
- tests:+18 added−0 removed
- other:+26 added−10 removed
Provenance
- Commit
9082e74- Tree
92201f5- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
7a7d77e
2 files changed+44 added−10 removed
modified:lib/application.js+26 added-10 removed
14 unmodified lines15 , View = require('./view')16 , url = require('url')17 , utils = connect.utils18 , path = require('path')19+ , http = require('http')20 , join = path.join21 , fs = require('fs')22 , qs = require('qs');23 156 unmodified lines180 * mounted applications.181 *182 * @param {String|Function|Server} route183 * @param {Function|Server} middleware183- * @return {Server} for chaining184+ * @return {app} for chaining185 * @api public186 */187 188 app.use = function(route, middleware){50 unmodified lines239 *240 * app.use(blog);241 *242 * @param {Function} fn242- * @return {Server} for chaining243+ * @return {app} for chaining244 * @api public245 */246 247 app.mounted = function(fn){13 unmodified lines261 * app.engine('html', require('ejs').render);262 *263 * @param {String} ext264 * @param {Function} fn264- * @return {Server} for chaining265+ * @return {app} for chaining266 * @api public267 */268 269 app.engine = function(ext, fn){56 unmodified lines326 * at [express-params](http://github.com/visionmedia/express-params).327 *328 * @param {String|Array|Function} name329 * @param {Function} fn329- * @return {Server} for chaining330+ * @return {app} for chaining331 * @api public332 */333 334 app.param = function(name, fn){25 unmodified lines360 * Register the given callback `fn` for the given `type`.361 *362 * @param {String} type363 * @param {Function} fn363- * @return {Server} for chaining364+ * @return {app} for chaining365 * @api public366 */367 368 app.is = function(type, fn){52 unmodified lines421 /**422 * Enable `setting`.423 *424 * @param {String} setting424- * @return {Server} for chaining425+ * @return {app} for chaining426 * @api public427 */428 429 app.enable = function(setting){3 unmodified lines433 /**434 * Disable `setting`.435 *436 * @param {String} setting436- * @return {Server} for chaining437+ * @return {app} for chaining438 * @api public439 */440 441 app.disable = function(setting){4 unmodified lines446 * Redirect `key` to `url`.447 *448 * @param {String} key449 * @param {String} url449- * @return {Server} for chaining450+ * @return {app} for chaining451 * @api public452 */453 454 app.redirect = function(key, url){22 unmodified lines477 * });478 *479 * @param {String} env...480 * @param {Function} fn480- * @return {Server} for chaining481+ * @return {app} for chaining482 * @api public483 */484 485 app.configure = function(env, fn){5 unmodified lines491 return this;492 };493 494 /**495+ * Listen for connections.496+ *497+ * This method takes the same arguments498+ * as node's `http.Server#listen()`. 499+ *500+ * @return {http.Server}501+ * @api public502+ */503+504+app.listen = function(){505+ var server = http.createServer(this);506+ return server.listen.apply(server, arguments);507+};508+509+/**510 * Delegate `.VERB(...)` calls to `.route(VERB, ...)`.511 */512 513 methods.forEach(function(method){10 unmodified lines524 * middleware, and callback to _every_ HTTP method.525 *526 * @param {String} path527 * @param {Function} ...512- * @return {Server} for chaining528+ * @return {app} for chaining529 * @api public530 */531 532 app.all = function(path){74 unmodified linesadded:test/app.listen.js+18 added
123456789101112131415161718
var express = require('../') , request = require('./support/http');
describe('app.listen()', function(){ it('should wrap with an HTTP server', function(done){ var app = express();
app.del('/tobi', function(req, res){ res.end('deleted tobi!'); });
var server = app.listen(9999, function(){ server.close(); done(); }); })})