Created
March 12, 2018 07:23
-
-
Save ttristan/0dd497fd272bbe83cda2ae7c4286e94b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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