Skip to content

Instantly share code, notes, and snippets.

@goloroden
Created February 26, 2012 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goloroden/1917727 to your computer and use it in GitHub Desktop.
Save goloroden/1917727 to your computer and use it in GitHub Desktop.
var middleware = function() {
return function(req, res, next) {
console.log('pre');
next();
console.log('post');
};
};
var connect = require('connect');
var http = require('http');
var app = connect()
.use(middleware())
.use(function(req, res) {
console.log('blablabla');
res.end('blablabla');
});
http.createServer(app).listen(3000); <== Throws an exception:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: addListener only takes instances of Function
at Server.<anonymous> (events.js:101:11)
at new Server (http.js:1333:10)
at Object.createServer (http.js:1350:10)
at Object.<anonymous> (/home/golo/test/test.js:32:6)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Array.0 (module.js:470:10)
at EventEmitter._tickCallback (node.js:192:40)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment