Skip to content

Instantly share code, notes, and snippets.

@ttristan
Created March 12, 2018 07:23
Show Gist options
  • Save ttristan/0dd497fd272bbe83cda2ae7c4286e94b to your computer and use it in GitHub Desktop.
Save ttristan/0dd497fd272bbe83cda2ae7c4286e94b to your computer and use it in GitHub Desktop.
const express = require("express");
const bodyParser = require("body-parser");
const path = require("path");
const cors = require("cors");
// Initialize http server
const app = express();
// setup
app.use(express.static(path.resolve(__dirname, "../build")));
app.use(cors());
app.use(bodyParser.urlencoded({ extended: true }));
//routs
app.get("/", (req, res) => {
res.sendFile(path.join(__dirname + "/index.html"));
});
// launch server
const server = app.listen(1024, () => {
const { address, port } = server.address();
console.log(`Listening at http://${address}:${port}`);
});
process.on("uncaughtException", err => {
if (err.code === "ENOTFOUND") return;
if (err.code === "ECONNRESET") return;
if (err.code === "PROTOCOL_CONNECTION_LOST") return;
console.log("UNCAUGHT ERROR", err);
console.log("UNCAUGHT ERROR", err.code);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment