app.ts
| 1 | import path from "node:path"; |
| 2 | import { staticPlugin } from "@elysiajs/static"; |
| 3 | import { Elysia } from "elysia"; |
| 4 | import config from "./config.ts"; |
| 5 | import { authRoutes } from "./routes/auth.tsx"; |
| 6 | import { avatarRoutes } from "./routes/avatars.ts"; |
| 7 | import { ciRoutes } from "./routes/ci.tsx"; |
| 8 | import { gitRoutes } from "./routes/git.ts"; |
| 9 | import { issueRoutes } from "./routes/issues.tsx"; |
| 10 | import { patchRoutes } from "./routes/patches.tsx"; |
| 11 | import { releasesRoutes } from "./routes/releases.tsx"; |
| 12 | import { repoRoutes } from "./routes/repos.tsx"; |
| 13 | import { settingsRoutes } from "./routes/settings.tsx"; |
| 14 | import { syncStartup } from "./services/repoSync.ts"; |
| 15 | |
| 16 | export async function createApp(port: number) { |
| 17 | await syncStartup(); |
| 18 | return new Elysia({ |
| 19 | serve: { maxRequestBodySize: config.MAX_UPLOAD_BYTES }, |
| 20 | }) |
| 21 | .use( |
| 22 | staticPlugin({ |
| 23 | assets: path.resolve("./public"), |
| 24 | prefix: "/", |
| 25 | }), |
| 26 | ) |
| 27 | .use(gitRoutes) |
| 28 | .use(settingsRoutes) |
| 29 | .use(authRoutes) |
| 30 | .use(repoRoutes) |
| 31 | .use(issueRoutes) |
| 32 | .use(patchRoutes) |
| 33 | .use(releasesRoutes) |
| 34 | .use(ciRoutes) |
| 35 | .use(avatarRoutes) |
| 36 | .listen(port); |
| 37 | } |
| 38 |