-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
62 lines (47 loc) · 1.3 KB
/
app.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
import express from "express";
import cors from "cors";
import passport from "passport";
import path from "path";
import { fileURLToPath } from "url";
import routerUsers from "./routes/api/users.js";
import routerRace from "./routes/api/race.js";
import routerPayment from "./routes/api/payment.js";
import "./config/config-passport.js";
import dotenv from "dotenv";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
dotenv.config();
const app = express();
app.use(express.json());
const corsOptions = {
origin: [
// "https://www.hematobieg.fundacja.hematologiczna.org",
"https://happy-island-035461003.5.azurestaticapps.net",
"https://secure.przelewy24.pl/trnRequest",
],
credentials: true,
};
app.use(cors(corsOptions));
app.use(passport.initialize());
app.use(express.static(path.join(__dirname, "public")));
// app.use("/api", router);
app.use("/api", routerUsers);
app.use("/api", routerRace);
app.use("/api", routerPayment);
app.use((_, res, __) => {
res.status(404).json({
status: "error",
code: 404,
message: "Not found",
data: "Not found",
});
});
app.use((err, _, res, __) => {
console.log(err.stack);
res.status(500).json({
status: "fail",
code: 500,
message: err.message,
data: "Internal Server Error",
});
});
export default app;