I am new to node and express. I have come across two ways of creating an express app that listens on a specific TCP port which, as far as I can tell, yield the same result. Could someone please shed some light to the difference to these, if there are any... It's the listen function
Method 1 - using the express module only:
var express = require('express');
var port = 8080;
var app = express();
app.set('port', port);
...
// different listen method
app.listen(app.get('port'), function(){
console.log('now listening on port ' + app.get('port'));
});
Method 2 - using the express and http modules:
var http = require('http'),
express = require('express');
var port = 8080;
var app = express();
app.set('port', port);
...
// different listen method
http.createServer(app).listen(app.get('port'), function(){
console.log('now listening on port ' + app.get('port'));
});