-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (26 loc) · 935 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const express = require("express");
const bodyParser = require("body-parser");
// Require firebase admin initialization
require("./config/firebase-admin");
// Initialize app
const app = express();
// Higher limit for adding series
app.use(bodyParser.json({ limit: "5mb" }));
// Connect to user database
require("./connections/usersDbConn");
// Connect to Newt Content database
require("./connections/newtContentDbConn");
// Require routes
require("./routes")(app);
if (process.env.NODE_ENV === "production") {
// Express will serve up production assets created after build process like
// main.js and main.css
app.use(express.static("client/build"));
// Express will serve up index.html if it does not recognize route
const path = require("path");
app.get("*", (req, res) =>
res.sendFile(path.resolve(__dirname, "client", "build", "index.html"))
);
}
const PORT = process.env.PORT || 9000;
app.listen(PORT);