-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
41 lines (35 loc) · 1.07 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
import express from "express";
import { userIsAuthenticated } from "./middleware/validateAuth";
import cors from "cors";
import handleError from "./middleware/errors";
import apiRouter from "./routers/apiRouter";
import passportConfig from "./auth/passport";
import generateSession from "./auth/session";
import _404Handler from "./middleware/404Handler";
import validateRequestMethod from "./middleware/validateRequestMethod";
import flash from "express-flash";
const app: express.Application = express();
app.set("trust proxy", 1);
app.use(flash());
app.use(
cors({
origin: [
"http://localhost:4200",
"https://localhost:4200",
"http://127.0.0.1:5501",
"https://xpulse.vercel.app",
"https://majid-l.github.io",
],
allowedHeaders: ["Content-Type", "Authorization"],
credentials: true,
})
);
app.use(express.json());
generateSession(app);
passportConfig(app);
app.use(validateRequestMethod);
app.use("/api/customers/:customerId", userIsAuthenticated);
app.use("/api", apiRouter);
app.use(handleError);
app.use(_404Handler);
export default app;