Blame · Line-by-line history
app.tsx
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| 79136bb | 1 | import { Hono } from "hono"; |
| 2 | import { logger } from "hono/logger"; | |
| 3 | import { cors } from "hono/cors"; | |
| 4 | import { Layout } from "./views/layout"; | |
| 5 | import gitRoutes from "./routes/git"; | |
| 6 | import apiRoutes from "./routes/api"; | |
| 7 | import authRoutes from "./routes/auth"; | |
| 8 | import settingsRoutes from "./routes/settings"; | |
| 9 | import issueRoutes from "./routes/issues"; | |
| 10 | import repoSettings from "./routes/repo-settings"; | |
| 11 | import compareRoutes from "./routes/compare"; | |
| 0074234 | 12 | import pullRoutes from "./routes/pulls"; |
| 13 | import editorRoutes from "./routes/editor"; | |
| c81ab7a | 14 | import forkRoutes from "./routes/fork"; |
| 15 | import webhookRoutes from "./routes/webhooks"; | |
| 16 | import exploreRoutes from "./routes/explore"; | |
| 17 | import tokenRoutes from "./routes/tokens"; | |
| 43de941 | 18 | import contributorRoutes from "./routes/contributors"; |
| 2c34075 | 19 | import healthRoutes from "./routes/health"; |
| 79136bb | 20 | import webRoutes from "./routes/web"; |
| 21 | ||
| 22 | const app = new Hono(); | |
| 23 | ||
| 24 | // Middleware | |
| 25 | app.use("*", logger()); | |
| 26 | app.use("/api/*", cors()); | |
| 27 | ||
| 28 | // Git Smart HTTP protocol routes (must be before web routes) | |
| 29 | app.route("/", gitRoutes); | |
| 30 | ||
| 31 | // REST API | |
| 32 | app.route("/", apiRoutes); | |
| 33 | ||
| 34 | // Auth routes (register, login, logout) | |
| 35 | app.route("/", authRoutes); | |
| 36 | ||
| 37 | // Settings routes (profile, SSH keys) | |
| 38 | app.route("/", settingsRoutes); | |
| 39 | ||
| c81ab7a | 40 | // API tokens |
| 41 | app.route("/", tokenRoutes); | |
| 42 | ||
| 79136bb | 43 | // Repo settings (description, visibility, delete) |
| 44 | app.route("/", repoSettings); | |
| 45 | ||
| c81ab7a | 46 | // Webhooks management |
| 47 | app.route("/", webhookRoutes); | |
| 48 | ||
| 79136bb | 49 | // Compare view (branch diffs) |
| 50 | app.route("/", compareRoutes); | |
| 51 | ||
| 52 | // Issue tracker | |
| 53 | app.route("/", issueRoutes); | |
| 54 | ||
| 0074234 | 55 | // Pull requests |
| 56 | app.route("/", pullRoutes); | |
| 57 | ||
| c81ab7a | 58 | // Fork |
| 59 | app.route("/", forkRoutes); | |
| 60 | ||
| 0074234 | 61 | // Web file editor |
| 62 | app.route("/", editorRoutes); | |
| 63 | ||
| 43de941 | 64 | // Contributors |
| 65 | app.route("/", contributorRoutes); | |
| 66 | ||
| 2c34075 | 67 | // Health dashboard |
| 68 | app.route("/", healthRoutes); | |
| 69 | ||
| c81ab7a | 70 | // Explore page |
| 71 | app.route("/", exploreRoutes); | |
| 72 | ||
| 79136bb | 73 | // Web UI (catch-all, must be last) |
| 74 | app.route("/", webRoutes); | |
| 75 | ||
| 76 | // Global 404 | |
| 77 | app.notFound((c) => { | |
| 78 | return c.html( | |
| 79 | <Layout title="Not Found"> | |
| 80 | <div class="empty-state"> | |
| 81 | <h2>404</h2> | |
| 82 | <p>Page not found.</p> | |
| 83 | <a href="/" style="margin-top: 12px; display: inline-block"> | |
| 84 | Go home | |
| 85 | </a> | |
| 86 | </div> | |
| 87 | </Layout>, | |
| 88 | 404 | |
| 89 | ); | |
| 90 | }); | |
| 91 | ||
| 92 | // Global error handler | |
| 93 | app.onError((err, c) => { | |
| 94 | console.error("[error]", err); | |
| 95 | return c.html( | |
| 96 | <Layout title="Error"> | |
| 97 | <div class="empty-state"> | |
| 98 | <h2>Something went wrong</h2> | |
| 99 | <p>An unexpected error occurred.</p> | |
| 100 | {process.env.NODE_ENV !== "production" && ( | |
| 101 | <pre style="margin-top: 16px; text-align: left; font-size: 12px; color: var(--red)"> | |
| 102 | {err.message} | |
| 103 | </pre> | |
| 104 | )} | |
| 105 | </div> | |
| 106 | </Layout>, | |
| 107 | 500 | |
| 108 | ); | |
| 109 | }); | |
| 110 | ||
| 111 | export default app; |