why do you need to store the port in express if you later set the port from var
ionutale opened this issue · comments
ion commented
generator/templates/js/www.ejs
Line 16 in d1f3fcc
/**
- Get port from environment and store in Express.
*/
var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);
/**
- Create HTTP server.
*/
var server = http.createServer(app);
/**
- Listen on provided port, on all network interfaces.
*/
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
please explain
Douglas Wilson commented
It is stored in a variable as it is used in multiple places in the file.
Douglas Wilson commented
As for storing in on express as a setting, it is not necessary, but a common convention to get the port in your other files with app.get('port')