Skip to content
This repository
Browse code

Added `app.listen()` for backwards compat

-ish
  • Loading branch information...
commit 6747ecc1c85499f067ad72ce8bfdc4f8b4a7f930 1 parent 6f303fb
TJ Holowaychuk authored February 27, 2012
15  lib/proto.js
@@ -183,3 +183,18 @@ app.handle = function(req, res, out) {
183 183
   }
184 184
   next();
185 185
 };
  186
+
  187
+/**
  188
+ * Listen for connections.
  189
+ *
  190
+ * This method takes the same arguments
  191
+ * as node's `http.Server#listen()`.  
  192
+ *
  193
+ * @return {http.Server}
  194
+ * @api public
  195
+ */
  196
+
  197
+app.listen = function(){
  198
+  var server = http.createServer(this);
  199
+  return server.listen.apply(server, arguments);
  200
+};
18  test/app.listen.js
... ...
@@ -0,0 +1,18 @@
  1
+
  2
+var connect = require('../');
  3
+
  4
+describe('app.listen()', function(){
  5
+  it('should wrap in an http.Server', function(done){
  6
+    var app = connect();
  7
+
  8
+    app.use(function(req, res){
  9
+      res.end();
  10
+    });
  11
+
  12
+    app.listen(5555, function(){
  13
+      app
  14
+      .request('/')
  15
+      .expect(200, done);
  16
+    });
  17
+  })
  18
+})

0 notes on commit 6747ecc

Please sign in to comment.
Something went wrong with that request. Please try again.