-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
40 lines (32 loc) · 853 Bytes
/
app.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
import express from "express";
import cors from "cors";
import fs from "fs";
import passport from "passport";
import middlewarePassport from "./service/passport";
import dotenv from "dotenv";
dotenv.config();
import apiRoutes from "./routes/api.routes";
const app = express();
// Settings
app.set("port", process.env.SERVER_PORT);
// Middlewares
app.use(cors());
app.use(express.json());
app.use(express.static("./client/build"));
app.use(express.urlencoded({ extended: false }));
// Passport
app.use(passport.initialize());
passport.use(middlewarePassport);
// Routes
app.use("/api", apiRoutes);
app.get("*", (req, res) => {
fs.readFile(
"./client/build/index.html",
{ encoding: "utf-8" },
(err, data) => {
if (!data) res.send("Server is running on Port 8000");
else res.send(data);
}
);
});
export default app;