-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
45 lines (36 loc) · 1.04 KB
/
index.ts
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
require("dotenv").config();
import { Database } from "./database";
import cors from "cors";
import bodyParser from "body-parser";
import express from "express";
import path from "path";
const database = new Database();
database.connect();
const app = express();
const port = process.env.PORT || 3000;
app.use(
bodyParser.urlencoded({
extended: true,
})
);
app.use(bodyParser.json());
app.use(cors());
import userRoute from "./routes/user";
app.use("/api/user", userRoute);
import roundRoute from "./routes/rounds";
app.use("/api/rounds", roundRoute);
import gameRoute from "./routes/game";
app.use("/api/game", gameRoute);
import statsRoute from "./routes/stats";
app.use("/api/stats", statsRoute);
import guestRoute from "./routes/guest";
app.use("/api/guest", guestRoute);
app.use(express.static("public"));
app.route("/*").get(function (req, res) {
res.sendFile(path.join(__dirname + "/public/index.html"), {
extensions: ["js"],
});
});
app.listen(port, () => {
console.log("My app is listening on port " + port);
});