import path from "node:path"; import { staticPlugin } from "@elysiajs/static"; import { Elysia } from "elysia"; import { MAX_UPLOAD_BYTES, PORT, SSH_DISABLED } from "./config.ts"; import { authRoutes } from "./routes/auth.tsx"; import { avatarRoutes } from "./routes/avatars.ts"; import { gitRoutes } from "./routes/git.ts"; import { issueRoutes } from "./routes/issues.tsx"; import { patchRoutes } from "./routes/patches.tsx"; import { releasesRoutes } from "./routes/releases.tsx"; import { repoRoutes } from "./routes/repos.tsx"; import { settingsRoutes } from "./routes/settings.tsx"; import { syncStartup } from "./services/repoSync.ts"; import { startSshServer } from "./services/sshServer.ts"; for (const cmd of ["git", "ssh-keygen"]) { const result = Bun.spawnSync(["which", cmd]); if (result.exitCode !== 0) { console.error(`Missing required command: ${cmd}`); process.exit(1); } } await syncStartup(); if (!SSH_DISABLED) await startSshServer(); const _app = new Elysia({ serve: { maxRequestBodySize: MAX_UPLOAD_BYTES } }) .use( staticPlugin({ assets: path.resolve("./public"), prefix: "/", }), ) .use(gitRoutes) .use(settingsRoutes) .use(authRoutes) .use(repoRoutes) .use(issueRoutes) .use(patchRoutes) .use(releasesRoutes) .use(avatarRoutes) .listen(PORT); console.log(`Hearthforge running at http://localhost:${PORT}`);