Last active
November 1, 2019 03:56
-
-
Save helloncanella/f44927201b44e891c400172968b38e60 to your computer and use it in GitHub Desktop.
basic-node-config
This file contains hidden or 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
require = require("esm")(module) | |
module.exports = require("./server") |
This file contains hidden or 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
{ | |
"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" | |
} | |
} |
This file contains hidden or 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
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