quakometer

git clone git://git.codymlewis.com/quakometer.git
Log | Files | Refs | LICENSE

commit af06e84f6d282e9098b8dbe82e4af7d8542c77b0
parent 5308072483295e9b4976cdff9e0f6018d969c7bc
Author: Cody Lewis <luxdotsugi@gmail.com>
Date:   Sat, 15 Sep 2018 23:54:47 +1000

Added port normalization

Diffstat:
Mapp.js | 15++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/app.js b/app.js @@ -1,7 +1,7 @@ const app = require("express")(); const server = require("http").Server(app); -const port = 8080; +var port = normalizePort(process.env.PORT || '8080'); console.log("Listening on *:" + port); server.listen(port); @@ -9,3 +9,16 @@ server.listen(port); app.get("/", (req, res) => { res.sendFile(__dirname + "/index.html"); }); + +function normalizePort(val) { + var port = parseInt(val, 10); + if (isNaN(port)) { + // named pipe + return val; + } + if (port >= 0) { + // port number + return port; + } + return false; +}