0

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 ??

Ben
  • 5,030
  • 6
  • 53
  • 94

1 Answers1

0

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.

G07cha
  • 4,009
  • 2
  • 22
  • 39
  • So there is no fundamental difference you're saying ? I was originally asking cause using it with passenger, exports does not work, but createServer does – Ben Sep 01 '16 at 13:20
  • Do you mean "express", right? For a node, in case of `http` you just creating server manually, everything else remains the same so if it works with passenger use the way it works with a passenger. – G07cha Sep 01 '16 at 14:36
  • Yep that does works the same; but as passenger is handling node differently and does a lot of things, i was concerned if changing this could lead to issues/downfalls; teying to understand better – Ben Sep 01 '16 at 15:29
  • @Ben, so your question should be "How to correctly integrate ExpressJS with Passenger?". And so you will have higher chance to get desired answer. – G07cha Sep 01 '16 at 15:32
  • it could have, but I felt this way to ask more straightforward, as the concern was about this specific difference – Ben Sep 03 '16 at 12:47