-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
48 lines (37 loc) · 1.52 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
42
43
44
45
46
47
48
import { Application } from "@oak/oak/application";
import { Router } from "@oak/oak/router";
import account_router from "./routes/account_router.ts";
import channels_router from "./routes/channels_router.ts";
import movies_router from "./routes/movies_router.ts";
import series_router from "./routes/series_router.ts";
import search_router from "./routes/search_router.ts";
import api_actions from "./components/api_actions.ts";
import GetSearchData from "./components/Search.ts";
import { oakCors } from "https://deno.land/x/cors/mod.ts";
Deno.cron("Get search data", "0 0 * * *", async () => {
const channels = new GetSearchData(api_actions.channels, "all_channels");
const series = new GetSearchData(api_actions.series, "all_series");
const movies = new GetSearchData(api_actions.movies, "all_movies");
await channels.get_data();
await series.get_data();
await movies.get_data();
});
const router = new Router();
router.get("/", (context) => {
context.response.body = "Halo v1.0.0 ◉";
});
const app = new Application();
app.use(oakCors({ origin: "*" }));
app.use(router.routes());
app.use(router.allowedMethods());
app.use(account_router.routes());
app.use(account_router.allowedMethods());
app.use(channels_router.routes());
app.use(channels_router.allowedMethods());
app.use(movies_router.routes());
app.use(movies_router.allowedMethods());
app.use(series_router.routes());
app.use(series_router.allowedMethods());
app.use(search_router.routes());
app.use(search_router.allowedMethods());
await app.listen({ port: 3000 });