CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
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"; | |
| 05b973e | 4 | import { compress } from "hono/compress"; |
| 79136bb | 5 | import { Layout } from "./views/layout"; |
| 3ef4c9d | 6 | import { requestContext } from "./middleware/request-context"; |
| 7 | import { rateLimit } from "./middleware/rate-limit"; | |
| 79136bb | 8 | import gitRoutes from "./routes/git"; |
| 9 | import apiRoutes from "./routes/api"; | |
| 10 | import authRoutes from "./routes/auth"; | |
| 11 | import settingsRoutes from "./routes/settings"; | |
| 7298a17 | 12 | import settings2faRoutes from "./routes/settings-2fa"; |
| 79136bb | 13 | import issueRoutes from "./routes/issues"; |
| 14 | import repoSettings from "./routes/repo-settings"; | |
| 15 | import compareRoutes from "./routes/compare"; | |
| 0074234 | 16 | import pullRoutes from "./routes/pulls"; |
| 17 | import editorRoutes from "./routes/editor"; | |
| c81ab7a | 18 | import forkRoutes from "./routes/fork"; |
| 19 | import webhookRoutes from "./routes/webhooks"; | |
| 20 | import exploreRoutes from "./routes/explore"; | |
| 21 | import tokenRoutes from "./routes/tokens"; | |
| 43de941 | 22 | import contributorRoutes from "./routes/contributors"; |
| 3ef4c9d | 23 | import notificationRoutes from "./routes/notifications"; |
| 24 | import dashboardRoutes from "./routes/dashboard"; | |
| 25 | import askRoutes from "./routes/ask"; | |
| 26 | import releaseRoutes from "./routes/releases"; | |
| 27 | import gateRoutes from "./routes/gates"; | |
| 28 | import insightsRoutes from "./routes/insights"; | |
| 29 | import searchRoutes from "./routes/search"; | |
| 30 | import healthRoutes from "./routes/health"; | |
| ad6d4ad | 31 | import hookRoutes from "./routes/hooks"; |
| 6fc53bd | 32 | import themeRoutes from "./routes/theme"; |
| 33 | import auditRoutes from "./routes/audit"; | |
| 34 | import reactionRoutes from "./routes/reactions"; | |
| 24cf2ca | 35 | import savedReplyRoutes from "./routes/saved-replies"; |
| 36 | import deploymentRoutes from "./routes/deployments"; | |
| 6563f0a | 37 | import orgRoutes from "./routes/orgs"; |
| 2df1f8c | 38 | import passkeyRoutes from "./routes/passkeys"; |
| 058d752 | 39 | import oauthRoutes from "./routes/oauth"; |
| 40 | import developerAppsRoutes from "./routes/developer-apps"; | |
| eafe8c6 | 41 | import workflowRoutes from "./routes/workflows"; |
| 25a91a6 | 42 | import packagesApiRoutes from "./routes/packages-api"; |
| 43 | import packagesUiRoutes from "./routes/packages"; | |
| 44 | import pagesRoutes from "./routes/pages"; | |
| 45 | import environmentsRoutes from "./routes/environments"; | |
| 3cbe3d6 | 46 | import aiExplainRoutes from "./routes/ai-explain"; |
| 47 | import aiChangelogRoutes from "./routes/ai-changelog"; | |
| 48 | import copilotRoutes from "./routes/copilot"; | |
| 49 | import depUpdaterRoutes from "./routes/dep-updater"; | |
| 50 | import semanticSearchRoutes from "./routes/semantic-search"; | |
| 1e162a8 | 51 | import aiTestsRoutes from "./routes/ai-tests"; |
| 52 | import discussionRoutes from "./routes/discussions"; | |
| 53 | import gistRoutes from "./routes/gists"; | |
| 54 | import projectRoutes from "./routes/projects"; | |
| 55 | import wikiRoutes from "./routes/wikis"; | |
| a79a9ed | 56 | import mergeQueueRoutes from "./routes/merge-queue"; |
| 57 | import requiredChecksRoutes from "./routes/required-checks"; | |
| 58 | import protectedTagsRoutes from "./routes/protected-tags"; | |
| 8f50ed0 | 59 | import trafficRoutes from "./routes/traffic"; |
| 60 | import orgInsightsRoutes from "./routes/org-insights"; | |
| 61 | import adminRoutes from "./routes/admin"; | |
| 62 | import billingRoutes from "./routes/billing"; | |
| eae38d1 | 63 | import pwaRoutes from "./routes/pwa"; |
| 64 | import graphqlRoutes from "./routes/graphql"; | |
| 06139e6 | 65 | import marketplaceRoutes from "./routes/marketplace"; |
| 79136bb | 66 | import webRoutes from "./routes/web"; |
| 67 | ||
| 68 | const app = new Hono(); | |
| 69 | ||
| 3ef4c9d | 70 | // Request context (request ID, start time) runs before everything else |
| 71 | app.use("*", requestContext); | |
| 05b973e | 72 | // Middleware — compression first (wraps all responses) |
| 73 | app.use("*", compress()); | |
| 74 | // Logger only on non-git routes to avoid overhead on clone/push | |
| 75 | app.use("*", async (c, next) => { | |
| 76 | if (c.req.path.includes(".git/")) return next(); | |
| 77 | return logger()(c, next); | |
| 78 | }); | |
| 79136bb | 79 | app.use("/api/*", cors()); |
| 3ef4c9d | 80 | // Rate-limit API + auth endpoints (generous default) |
| 81 | app.use("/api/*", rateLimit({ windowMs: 60_000, max: 120 })); | |
| 82 | app.use("/login", rateLimit({ windowMs: 60_000, max: 20 })); | |
| 83 | app.use("/register", rateLimit({ windowMs: 60_000, max: 10 })); | |
| 79136bb | 84 | |
| 85 | // Git Smart HTTP protocol routes (must be before web routes) | |
| 86 | app.route("/", gitRoutes); | |
| 87 | ||
| 3ef4c9d | 88 | // Health + metrics |
| 89 | app.route("/", healthRoutes); | |
| 90 | ||
| ad6d4ad | 91 | // Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs) |
| 92 | app.route("/", hookRoutes); | |
| 93 | ||
| 79136bb | 94 | // REST API |
| 95 | app.route("/", apiRoutes); | |
| 96 | ||
| 97 | // Auth routes (register, login, logout) | |
| 98 | app.route("/", authRoutes); | |
| 99 | ||
| 100 | // Settings routes (profile, SSH keys) | |
| 101 | app.route("/", settingsRoutes); | |
| 102 | ||
| 7298a17 | 103 | // 2FA / TOTP settings (Block B4) |
| 104 | app.route("/", settings2faRoutes); | |
| 105 | ||
| 2df1f8c | 106 | // WebAuthn / passkey routes (Block B5) |
| 107 | app.route("/", passkeyRoutes); | |
| 108 | ||
| 058d752 | 109 | // OAuth 2.0 provider (Block B6) |
| 110 | app.route("/", oauthRoutes); | |
| 111 | app.route("/", developerAppsRoutes); | |
| 112 | ||
| 6fc53bd | 113 | // Theme toggle (dark/light cookie) |
| 114 | app.route("/", themeRoutes); | |
| 115 | ||
| 116 | // Audit log UI | |
| 117 | app.route("/", auditRoutes); | |
| 118 | ||
| 119 | // Reactions API (issues, PRs, comments) | |
| 120 | app.route("/", reactionRoutes); | |
| 121 | ||
| 24cf2ca | 122 | // Saved replies (per-user canned comment templates) |
| 123 | app.route("/", savedReplyRoutes); | |
| 124 | ||
| 125 | // Environments + deployment history UI | |
| 126 | app.route("/", deploymentRoutes); | |
| 127 | ||
| 6563f0a | 128 | // Organizations + teams (Block B1) |
| 129 | app.route("/", orgRoutes); | |
| 130 | ||
| c81ab7a | 131 | // API tokens |
| 132 | app.route("/", tokenRoutes); | |
| 133 | ||
| 3ef4c9d | 134 | // Notifications inbox |
| 135 | app.route("/", notificationRoutes); | |
| 136 | ||
| 137 | // Dashboard (/dashboard) | |
| 138 | app.route("/", dashboardRoutes); | |
| 139 | ||
| 140 | // AI assistant — /ask + /:owner/:repo/ask | |
| 141 | app.route("/", askRoutes); | |
| 142 | ||
| 143 | // Global search | |
| 144 | app.route("/", searchRoutes); | |
| 145 | ||
| 79136bb | 146 | // Repo settings (description, visibility, delete) |
| 147 | app.route("/", repoSettings); | |
| 148 | ||
| c81ab7a | 149 | // Webhooks management |
| 150 | app.route("/", webhookRoutes); | |
| 151 | ||
| 79136bb | 152 | // Compare view (branch diffs) |
| 153 | app.route("/", compareRoutes); | |
| 154 | ||
| 155 | // Issue tracker | |
| 156 | app.route("/", issueRoutes); | |
| 157 | ||
| 0074234 | 158 | // Pull requests |
| 159 | app.route("/", pullRoutes); | |
| 160 | ||
| c81ab7a | 161 | // Fork |
| 162 | app.route("/", forkRoutes); | |
| 163 | ||
| 0074234 | 164 | // Web file editor |
| 165 | app.route("/", editorRoutes); | |
| 166 | ||
| 43de941 | 167 | // Contributors |
| 168 | app.route("/", contributorRoutes); | |
| 169 | ||
| 3ef4c9d | 170 | // Releases |
| 171 | app.route("/", releaseRoutes); | |
| 172 | ||
| 173 | // Gates (history + settings + branch protection) | |
| 174 | app.route("/", gateRoutes); | |
| 175 | ||
| eafe8c6 | 176 | // Actions-equivalent workflow runner (Block C1) |
| 177 | app.route("/", workflowRoutes); | |
| 178 | ||
| 25a91a6 | 179 | // Package registry — npm protocol + UI (Block C2) |
| 180 | app.route("/", packagesApiRoutes); | |
| 181 | app.route("/", packagesUiRoutes); | |
| 182 | ||
| 183 | // Pages / static hosting (Block C3) | |
| 184 | app.route("/", pagesRoutes); | |
| 185 | ||
| 186 | // Environments with protected approvals (Block C4) | |
| 187 | app.route("/", environmentsRoutes); | |
| 188 | ||
| 3cbe3d6 | 189 | // AI-native features (Block D) |
| 190 | app.route("/", aiExplainRoutes); // D6 — /:owner/:repo/explain | |
| 191 | app.route("/", aiChangelogRoutes); // D7 — /:owner/:repo/ai/changelog | |
| 192 | app.route("/", copilotRoutes); // D9 — /api/copilot/completions | |
| 193 | app.route("/", depUpdaterRoutes); // D2 — /:owner/:repo/settings/dep-updater | |
| 194 | app.route("/", semanticSearchRoutes); // D1 — /:owner/:repo/search/semantic | |
| 1e162a8 | 195 | app.route("/", aiTestsRoutes); // D8 — /:owner/:repo/ai/tests |
| 196 | app.route("/", discussionRoutes); // E2 — /:owner/:repo/discussions | |
| 197 | app.route("/", gistRoutes); // E4 — /gists, /gists/:slug, /:user/gists | |
| 198 | app.route("/", projectRoutes); // E1 — /:owner/:repo/projects | |
| 199 | app.route("/", wikiRoutes); // E3 — /:owner/:repo/wiki | |
| a79a9ed | 200 | app.route("/", mergeQueueRoutes); // E5 — /:owner/:repo/queue |
| 201 | app.route("/", requiredChecksRoutes); // E6 — /:owner/:repo/gates/protection/:id/checks | |
| 202 | app.route("/", protectedTagsRoutes); // E7 — /:owner/:repo/settings/protected-tags | |
| 8f50ed0 | 203 | app.route("/", trafficRoutes); // F1 — /:owner/:repo/traffic |
| 204 | app.route("/", orgInsightsRoutes); // F2 — /orgs/:slug/insights | |
| 205 | app.route("/", adminRoutes); // F3 — /admin | |
| 206 | app.route("/", billingRoutes); // F4 — /settings/billing + /admin/billing | |
| 3cbe3d6 | 207 | |
| eae38d1 | 208 | // PWA — manifest + service worker + icon (Block G1) |
| 209 | app.route("/", pwaRoutes); | |
| 210 | ||
| 211 | // GraphQL mirror of REST (Block G2) | |
| 212 | app.route("/", graphqlRoutes); | |
| 213 | ||
| 06139e6 | 214 | // Marketplace + app installations + bot identities (Block H1 + H2) |
| 215 | app.route("/", marketplaceRoutes); | |
| 216 | ||
| 3ef4c9d | 217 | // Insights + milestones |
| 218 | app.route("/", insightsRoutes); | |
| 219 | ||
| c81ab7a | 220 | // Explore page |
| 221 | app.route("/", exploreRoutes); | |
| 222 | ||
| 79136bb | 223 | // Web UI (catch-all, must be last) |
| 224 | app.route("/", webRoutes); | |
| 225 | ||
| 226 | // Global 404 | |
| 227 | app.notFound((c) => { | |
| 228 | return c.html( | |
| 229 | <Layout title="Not Found"> | |
| 230 | <div class="empty-state"> | |
| 231 | <h2>404</h2> | |
| 232 | <p>Page not found.</p> | |
| 233 | <a href="/" style="margin-top: 12px; display: inline-block"> | |
| 234 | Go home | |
| 235 | </a> | |
| 236 | </div> | |
| 237 | </Layout>, | |
| 238 | 404 | |
| 239 | ); | |
| 240 | }); | |
| 241 | ||
| 242 | // Global error handler | |
| 243 | app.onError((err, c) => { | |
| 244 | console.error("[error]", err); | |
| 245 | return c.html( | |
| 246 | <Layout title="Error"> | |
| 247 | <div class="empty-state"> | |
| 248 | <h2>Something went wrong</h2> | |
| 249 | <p>An unexpected error occurred.</p> | |
| 250 | {process.env.NODE_ENV !== "production" && ( | |
| 251 | <pre style="margin-top: 16px; text-align: left; font-size: 12px; color: var(--red)"> | |
| 252 | {err.message} | |
| 253 | </pre> | |
| 254 | )} | |
| 255 | </div> | |
| 256 | </Layout>, | |
| 257 | 500 | |
| 258 | ); | |
| 259 | }); | |
| 260 | ||
| 261 | export default app; |