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