Both :
app.listen( port, function () {
.. doing stuff ..
});
module.exports = app;
and
http.createServer(app).listen(port)
Will do quite the same. What's the main difference ??
Well, module.exports
here is just for testing or extending proposes, so you can require app
in your test and work with it. In another hand, app.listen
is much shorter and cleaner syntax.