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