-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
62 lines (52 loc) · 1.46 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
56
57
58
59
60
61
62
const express = require("express");
let app = express();
//use path for dev
require("dotenv").config({ path: "config.env" });
// require("dotenv").config();
const PORT = process.env.PORT || 3000;
app.use(express.json());
app.use(
express.urlencoded({
extended: true,
})
);
const cors = require("cors");
// app.options("*", cors());
// app.use(
// cors({
// origin: ["*"],
// credentials: true,
// })
// );
app.use((req, res, next) => {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Methods", "GET,PUT,POST, PATCH,DELETE");
res.header("Access-Control-Allow-Headers", "Content-Type");
app.use(cors());
next();
});
// app.use(function (req, res, next) {
// res.header("Access-Control-Allow-Origin", "*");
// res.header(
// "Access-Control-Allow-Methods",
// "GET, PUT, PATCH, POST, DELETE, OPTIONS"
// );
// res.header(
// "Access-Control-Allow-Headers",
// "Origin, X-Requested-With, Content-Type, Accept"
// );
// next();
// });
const gameMethodsRouter = require("./routes/gameRoutes");
app.use(gameMethodsRouter.router0);
app.use(gameMethodsRouter.router1);
app.use(gameMethodsRouter.router2);
app.use(gameMethodsRouter.router3);
app.use(gameMethodsRouter.router4);
app.use(gameMethodsRouter.router5);
app.use(gameMethodsRouter.router6);
app.use(gameMethodsRouter.router7);
app.use(gameMethodsRouter.router8);
app.listen(PORT, () => {
console.log(`Example app listening at ${PORT}`);
});