-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.ts
41 lines (34 loc) · 1.01 KB
/
main.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 cron from "node-cron";
import cors from "cors";
import cookieParser from "cookie-parser";
import v1 from "./routes/v1/v1.js";
import { updateFeaturedStreamers } from "./helper/updateFeaturedStreamers.js";
const port = 3005;
const app = express();
app.use(
cors({
origin:
process.env.NODE_ENV === "production"
? "https://d2jam.com"
: `http://localhost:${process.env.FRONT_DEV_PORT || 3000}`,
credentials: true,
allowedHeaders: ["Content-Type", "Authorization"],
exposedHeaders: ["Authorization"],
})
);
app.use(cookieParser());
app.use(express.json());
app.use("/api/v1", v1);
cron.schedule("*/5 * * * *", async () => {
console.log("Running updateFeaturedStreamers...");
try {
await updateFeaturedStreamers();
console.log("Successfully updated featured streamers.");
} catch (error) {
console.error("Error updating featured streamers:", error);
}
});
app.listen(port, () => {
console.log(`Jamcore listening on port ${port}`);
});