-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
55 lines (45 loc) · 1.1 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//To enable .env file
require("dotenv").config();
const express = require("express");
const app = express();
//Set static folder
app.use(express.static("presidio/build"));
//Cookie
const cookieParser = require("cookie-parser");
app.use(cookieParser());
//CORS
var cors = require("cors");
var corsOptions = {
origin: ["http://localhost:3000", "http://192.168.0.150:3000"],
optionsSuccessStatus: 200, // some legacy browsers (IE11, various SmartTVs) choke on 204
credentials: true,
};
app.use(cors(corsOptions));
//DB connection
require("./src/models/");
//body parser deprecation replacement
app.use(express.json());
app.use(
express.urlencoded({
extended: true,
})
);
//import routes
const routes = require("./src/routes/");
app.use(routes);
//Client route
const path = require("path");
app.get("/", (req, res) => {
const client_folder = "presidio";
const client_path = path.join(
__dirname,
client_folder,
"build",
"index.html"
);
res.sendFile(client_path);
});
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => {
console.log(`Server started on port ${PORT}`);
});