-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (26 loc) · 928 Bytes
/
app.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
36
37
const express = require("express");
const mongoose = require("mongoose");
const keys = require("./config/keys");
const bodyParser = require("body-parser");
const { isAuth } = require("./services/isAuth");
const cors = require("cors");
const http = require("http");
mongoose.connect(keys.MONGO_KEY, { useNewUrlParser: true });
const app = express();
app.use(cors());
app.use(isAuth);
app.use(bodyParser.json());
require("./routes/authRoutes")(app);
require("./routes/movieRoutes")(app);
const PORT = process.env.PORT || 5000;
if (process.env.NODE_ENV == "production") {
setInterval(function() {
http.get("https://mo-hub.herokuapp.com/");
}, 300000);
app.use(express.static("client/dist"));
const path = require("path");
app.get("*", (req, res) => {
res.sendFile(path.resolve(__dirname, "client", "dist", "index.html"));
});
}
app.listen(PORT, () => console.log(`server running on port: ${PORT}`));