Skip to content

Instantly share code, notes, and snippets.

@helloncanella
Last active November 1, 2019 03:56
Show Gist options
  • Save helloncanella/f44927201b44e891c400172968b38e60 to your computer and use it in GitHub Desktop.
Save helloncanella/f44927201b44e891c400172968b38e60 to your computer and use it in GitHub Desktop.
basic-node-config
require = require("esm")(module)
module.exports = require("./server")
{
"name": "playground",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"esm": "^3.2.25",
"express": "^4.17.1",
"lodash": "^4.17.15",
"nodemon": "^1.19.1"
},
"nodemonConfig": {
"ignore": [
"client/*",
"**/*.json"
],
"delay": "100"
}
}
import fs from "fs"
import http from "http"
import express from "express"
import path from "path"
import _ from "lodash"
const PORT = process.env.PORT || process.env.DEV_PORT || 3015
const app = express()
const httpServer = http.createServer(app)
// Serve static files from the React app
app.use(express.static(path.join(__dirname, "client/build")))
app.get("*", (req, res) => {
res.sendFile(path.join(__dirname + "/client/build/index.html"))
})
httpServer.listen(PORT, () => {
console.log(`🚀 Server ready at http://localhost:${PORT}`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment