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"; |
| 79136bb | 19 | import webRoutes from "./routes/web"; |
| 20 | ||
| 21 | const app = new Hono(); | |
| 22 | ||
| 23 | // Middleware | |
| 24 | app.use("*", logger()); | |
| 25 | app.use("/api/*", cors()); | |
| 26 | ||
| 27 | // Git Smart HTTP protocol routes (must be before web routes) | |
| 28 | app.route("/", gitRoutes); | |
| 29 | ||
| 30 | // REST API | |
| 31 | app.route("/", apiRoutes); | |
| 32 | ||
| 33 | // Auth routes (register, login, logout) | |
| 34 | app.route("/", authRoutes); | |
| 35 | ||
| 36 | // Settings routes (profile, SSH keys) | |
| 37 | app.route("/", settingsRoutes); | |
| 38 | ||
| c81ab7a | 39 | // API tokens |
| 40 | app.route("/", tokenRoutes); | |
| 41 | ||
| 79136bb | 42 | // Repo settings (description, visibility, delete) |
| 43 | app.route("/", repoSettings); | |
| 44 | ||
| c81ab7a | 45 | // Webhooks management |
| 46 | app.route("/", webhookRoutes); | |
| 47 | ||
| 79136bb | 48 | // Compare view (branch diffs) |
| 49 | app.route("/", compareRoutes); | |
| 50 | ||
| 51 | // Issue tracker | |
| 52 | app.route("/", issueRoutes); | |
| 53 | ||
| 0074234 | 54 | // Pull requests |
| 55 | app.route("/", pullRoutes); | |
| 56 | ||
| c81ab7a | 57 | // Fork |
| 58 | app.route("/", forkRoutes); | |
| 59 | ||
| 0074234 | 60 | // Web file editor |
| 61 | app.route("/", editorRoutes); | |
| 62 | ||
| 43de941 | 63 | // Contributors |
| 64 | app.route("/", contributorRoutes); | |
| 65 | ||
| c81ab7a | 66 | // Explore page |
| 67 | app.route("/", exploreRoutes); | |
| 68 | ||
| 79136bb | 69 | // Web UI (catch-all, must be last) |
| 70 | app.route("/", webRoutes); | |
| 71 | ||
| 72 | // Global 404 | |
| 73 | app.notFound((c) => { | |
| 74 | return c.html( | |
| 75 | <Layout title="Not Found"> | |
| 76 | <div class="empty-state"> | |
| 77 | <h2>404</h2> | |
| 78 | <p>Page not found.</p> | |
| 79 | <a href="/" style="margin-top: 12px; display: inline-block"> | |
| 80 | Go home | |
| 81 | </a> | |
| 82 | </div> | |
| 83 | </Layout>, | |
| 84 | 404 | |
| 85 | ); | |
| 86 | }); | |
| 87 | ||
| 88 | // Global error handler | |
| 89 | app.onError((err, c) => { | |
| 90 | console.error("[error]", err); | |
| 91 | return c.html( | |
| 92 | <Layout title="Error"> | |
| 93 | <div class="empty-state"> | |
| 94 | <h2>Something went wrong</h2> | |
| 95 | <p>An unexpected error occurred.</p> | |
| 96 | {process.env.NODE_ENV !== "production" && ( | |
| 97 | <pre style="margin-top: 16px; text-align: left; font-size: 12px; color: var(--red)"> | |
| 98 | {err.message} | |
| 99 | </pre> | |
| 100 | )} | |
| 101 | </div> | |
| 102 | </Layout>, | |
| 103 | 500 | |
| 104 | ); | |
| 105 | }); | |
| 106 | ||
| 107 | export default app; |