server.js 2/4

PHOTO EMBED

Tue Sep 07 2021 19:27:15 GMT+0000 (Coordinated Universal Time)

Saved by @devdave

// [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);
content_copyCOPY