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