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"; | |
| 12 | import webRoutes from "./routes/web"; | |
| 13 | ||
| 14 | const app = new Hono(); | |
| 15 | ||
| 16 | // Middleware | |
| 17 | app.use("*", logger()); | |
| 18 | app.use("/api/*", cors()); | |
| 19 | ||
| 20 | // Git Smart HTTP protocol routes (must be before web routes) | |
| 21 | app.route("/", gitRoutes); | |
| 22 | ||
| 23 | // REST API | |
| 24 | app.route("/", apiRoutes); | |
| 25 | ||
| 26 | // Auth routes (register, login, logout) | |
| 27 | app.route("/", authRoutes); | |
| 28 | ||
| 29 | // Settings routes (profile, SSH keys) | |
| 30 | app.route("/", settingsRoutes); | |
| 31 | ||
| 32 | // Repo settings (description, visibility, delete) | |
| 33 | app.route("/", repoSettings); | |
| 34 | ||
| 35 | // Compare view (branch diffs) | |
| 36 | app.route("/", compareRoutes); | |
| 37 | ||
| 38 | // Issue tracker | |
| 39 | app.route("/", issueRoutes); | |
| 40 | ||
| 41 | // Web UI (catch-all, must be last) | |
| 42 | app.route("/", webRoutes); | |
| 43 | ||
| 44 | // Global 404 | |
| 45 | app.notFound((c) => { | |
| 46 | return c.html( | |
| 47 | <Layout title="Not Found"> | |
| 48 | <div class="empty-state"> | |
| 49 | <h2>404</h2> | |
| 50 | <p>Page not found.</p> | |
| 51 | <a href="/" style="margin-top: 12px; display: inline-block"> | |
| 52 | Go home | |
| 53 | </a> | |
| 54 | </div> | |
| 55 | </Layout>, | |
| 56 | 404 | |
| 57 | ); | |
| 58 | }); | |
| 59 | ||
| 60 | // Global error handler | |
| 61 | app.onError((err, c) => { | |
| 62 | console.error("[error]", err); | |
| 63 | return c.html( | |
| 64 | <Layout title="Error"> | |
| 65 | <div class="empty-state"> | |
| 66 | <h2>Something went wrong</h2> | |
| 67 | <p>An unexpected error occurred.</p> | |
| 68 | {process.env.NODE_ENV !== "production" && ( | |
| 69 | <pre style="margin-top: 16px; text-align: left; font-size: 12px; color: var(--red)"> | |
| 70 | {err.message} | |
| 71 | </pre> | |
| 72 | )} | |
| 73 | </div> | |
| 74 | </Layout>, | |
| 75 | 500 | |
| 76 | ); | |
| 77 | }); | |
| 78 | ||
| 79 | export default app; |