-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
33 lines (28 loc) · 936 Bytes
/
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
import express from "express";
import { apiRouter } from "./routes/api";
import passport from "passport";
import bodyParser from "body-parser";
import { log } from "./utils/logging";
import * as path from "path";
const app = express();
const PORT = process.env.PORT ?? 8000;
app.use(passport.initialize());
app.use(passport.session());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(
"/api",
(req, res, next) => {
log.info("===================================================");
log.route(`Processing request ${req.method} ${req.path}`);
next();
},
apiRouter
);
app.use(express.static(path.join(__dirname, "web", "build")));
app.get("/*", function (req, res) {
res.sendFile(path.resolve(__dirname, "web", "build", "index.html"));
});
app.listen(PORT, () => {
console.log(`⚡️[server]: Server is running at https://localhost:${PORT}`);
});