// [2] SERVER SECT. // returns a valid PORT as a nbr or a string const normalizePort = (val) => { const port = parseInt(val, 10); if (isNaN(port)) { return val; } if (port >= 0) { return port; } return false; }; // env variable | setting up default port const port = normalizePort(process.env.PORT); // tells express which port to set app.set("port", port);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter