Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 2 additions & 24 deletions bin/rerum_v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dotenv.config()
* Get port from environment and store in Express.
*/

var port = normalizePort(process.env.PORT ?? '3001')
var port = process.env.PORT ?? 3001
app.set('port', port)

/**
Expand All @@ -40,26 +40,6 @@ server.keepAliveTimeout = 8 * 1000 //8 seconds
// Ensure the headersTimeout is set higher than the keepAliveTimeout due to this nodejs regression bug: https://github.com/nodejs/node/issues/27363
server.headersTimeout = 8.5 * 1000 //8 seconds

/**
* Normalize a port into a number, string, or false.
*/

function normalizePort(val) {
const portCheck = parseInt(val, 10)

if (isNaN(portCheck)) {
// named pipe
return val
}

if (portCheck >= 0) {
// port number
return portCheck
}

return false
}

/**
* Event listener for HTTP server "error" event.
*/
Expand All @@ -69,9 +49,7 @@ function onError(error) {
throw error
}

var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port
var bind = `Port ${port}`

// handle specific listen errors with friendly messages
switch (error.code) {
Expand Down