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"; |
| 71cd5ec | 66 | import templatesRoutes from "./routes/templates"; |
| 08420cd | 67 | import codeScanningRoutes from "./routes/code-scanning"; |
| 68 | import sponsorsRoutes from "./routes/sponsors"; | |
| 4c8f666 | 69 | import symbolsRoutes from "./routes/symbols"; |
| 4a0dea1 | 70 | import mirrorsRoutes from "./routes/mirrors"; |
| edf7c36 | 71 | import ssoRoutes from "./routes/sso"; |
| 8098672 | 72 | import depsRoutes from "./routes/deps"; |
| f60ccde | 73 | import advisoriesRoutes from "./routes/advisories"; |
| 3951454 | 74 | import signingKeysRoutes from "./routes/signing-keys"; |
| 7aa8b99 | 75 | import followsRoutes from "./routes/follows"; |
| 9ff7128 | 76 | import rulesetsRoutes from "./routes/rulesets"; |
| 0cdfd89 | 77 | import commitStatusesRoutes from "./routes/commit-statuses"; |
| 3648956 | 78 | import badgesRoutes from "./routes/badges"; |
| f9e7c01 | 79 | import communityRoutes from "./routes/community"; |
| 8ec29ff | 80 | import pinnedReposRoutes from "./routes/pinned-repos"; |
| 7c975c6 | 81 | import pulseRoutes from "./routes/pulse"; |
| 26484eb | 82 | import feedRoutes from "./routes/feeds"; |
| d6b4e67 | 83 | import staleIssuesRoutes from "./routes/stale-issues"; |
| f3e1844 | 84 | import codeownersLintRoutes from "./routes/codeowners-lint"; |
| 7c0203e | 85 | import codeSuggestionsRoutes from "./routes/code-suggestions"; |
| d6daf49 | 86 | import branchRenameRoutes from "./routes/branch-rename"; |
| 9090df3 | 87 | import responseTimeRoutes from "./routes/response-time"; |
| c02a55b | 88 | import branchAgeRoutes from "./routes/branch-age"; |
| b184a75 | 89 | import issueSimilarityRoutes from "./routes/issue-similarity"; |
| 8c5346c | 90 | import prLeadTimeRoutes from "./routes/pr-lead-time"; |
| 07efa08 | 91 | import languageRoutes from "./routes/languages"; |
| ce08e97 | 92 | import repoSizeRoutes from "./routes/repo-size"; |
| 28bc555 | 93 | import prSizeRoutes from "./routes/pr-size"; |
| 79136bb | 94 | import webRoutes from "./routes/web"; |
| 95 | ||
| 96 | const app = new Hono(); | |
| 97 | ||
| 3ef4c9d | 98 | // Request context (request ID, start time) runs before everything else |
| 99 | app.use("*", requestContext); | |
| 05b973e | 100 | // Middleware — compression first (wraps all responses) |
| 101 | app.use("*", compress()); | |
| 102 | // Logger only on non-git routes to avoid overhead on clone/push | |
| 103 | app.use("*", async (c, next) => { | |
| 104 | if (c.req.path.includes(".git/")) return next(); | |
| 105 | return logger()(c, next); | |
| 106 | }); | |
| 79136bb | 107 | app.use("/api/*", cors()); |
| 3ef4c9d | 108 | // Rate-limit API + auth endpoints (generous default) |
| 109 | app.use("/api/*", rateLimit({ windowMs: 60_000, max: 120 })); | |
| 110 | app.use("/login", rateLimit({ windowMs: 60_000, max: 20 })); | |
| 111 | app.use("/register", rateLimit({ windowMs: 60_000, max: 10 })); | |
| 79136bb | 112 | |
| 113 | // Git Smart HTTP protocol routes (must be before web routes) | |
| 114 | app.route("/", gitRoutes); | |
| 115 | ||
| 3ef4c9d | 116 | // Health + metrics |
| 117 | app.route("/", healthRoutes); | |
| 118 | ||
| ad6d4ad | 119 | // Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs) |
| 120 | app.route("/", hookRoutes); | |
| 121 | ||
| 79136bb | 122 | // REST API |
| 123 | app.route("/", apiRoutes); | |
| 124 | ||
| 125 | // Auth routes (register, login, logout) | |
| 126 | app.route("/", authRoutes); | |
| 127 | ||
| 128 | // Settings routes (profile, SSH keys) | |
| 129 | app.route("/", settingsRoutes); | |
| 130 | ||
| 7298a17 | 131 | // 2FA / TOTP settings (Block B4) |
| 132 | app.route("/", settings2faRoutes); | |
| 133 | ||
| 2df1f8c | 134 | // WebAuthn / passkey routes (Block B5) |
| 135 | app.route("/", passkeyRoutes); | |
| 136 | ||
| 058d752 | 137 | // OAuth 2.0 provider (Block B6) |
| 138 | app.route("/", oauthRoutes); | |
| 139 | app.route("/", developerAppsRoutes); | |
| 140 | ||
| 6fc53bd | 141 | // Theme toggle (dark/light cookie) |
| 142 | app.route("/", themeRoutes); | |
| 143 | ||
| 144 | // Audit log UI | |
| 145 | app.route("/", auditRoutes); | |
| 146 | ||
| 147 | // Reactions API (issues, PRs, comments) | |
| 148 | app.route("/", reactionRoutes); | |
| 149 | ||
| 24cf2ca | 150 | // Saved replies (per-user canned comment templates) |
| 151 | app.route("/", savedReplyRoutes); | |
| 152 | ||
| 153 | // Environments + deployment history UI | |
| 154 | app.route("/", deploymentRoutes); | |
| 155 | ||
| 6563f0a | 156 | // Organizations + teams (Block B1) |
| 157 | app.route("/", orgRoutes); | |
| 158 | ||
| c81ab7a | 159 | // API tokens |
| 160 | app.route("/", tokenRoutes); | |
| 161 | ||
| 3ef4c9d | 162 | // Notifications inbox |
| 163 | app.route("/", notificationRoutes); | |
| 164 | ||
| 165 | // Dashboard (/dashboard) | |
| 166 | app.route("/", dashboardRoutes); | |
| 167 | ||
| 168 | // AI assistant — /ask + /:owner/:repo/ask | |
| 169 | app.route("/", askRoutes); | |
| 170 | ||
| 171 | // Global search | |
| 172 | app.route("/", searchRoutes); | |
| 173 | ||
| 79136bb | 174 | // Repo settings (description, visibility, delete) |
| 175 | app.route("/", repoSettings); | |
| 176 | ||
| c81ab7a | 177 | // Webhooks management |
| 178 | app.route("/", webhookRoutes); | |
| 179 | ||
| 79136bb | 180 | // Compare view (branch diffs) |
| 181 | app.route("/", compareRoutes); | |
| 182 | ||
| d6b4e67 | 183 | // Stale issue detector — must be BEFORE issueRoutes so the static |
| 184 | // `/issues/stale` path wins over the dynamic `/issues/:number` (Block J20). | |
| 185 | app.route("/", staleIssuesRoutes); | |
| 186 | ||
| b184a75 | 187 | // Issue similarity / duplicate suggestions — must be BEFORE issueRoutes so |
| 188 | // the static `/issues/similar.json` path wins over `/issues/:number` (J28). | |
| 189 | app.route("/", issueSimilarityRoutes); | |
| 190 | ||
| 79136bb | 191 | // Issue tracker |
| 192 | app.route("/", issueRoutes); | |
| 193 | ||
| 0074234 | 194 | // Pull requests |
| 195 | app.route("/", pullRoutes); | |
| 196 | ||
| c81ab7a | 197 | // Fork |
| 198 | app.route("/", forkRoutes); | |
| 199 | ||
| 0074234 | 200 | // Web file editor |
| 201 | app.route("/", editorRoutes); | |
| 202 | ||
| 43de941 | 203 | // Contributors |
| 204 | app.route("/", contributorRoutes); | |
| 205 | ||
| 3ef4c9d | 206 | // Releases |
| 207 | app.route("/", releaseRoutes); | |
| 208 | ||
| 209 | // Gates (history + settings + branch protection) | |
| 210 | app.route("/", gateRoutes); | |
| 211 | ||
| eafe8c6 | 212 | // Actions-equivalent workflow runner (Block C1) |
| 213 | app.route("/", workflowRoutes); | |
| 214 | ||
| 25a91a6 | 215 | // Package registry — npm protocol + UI (Block C2) |
| 216 | app.route("/", packagesApiRoutes); | |
| 217 | app.route("/", packagesUiRoutes); | |
| 218 | ||
| 219 | // Pages / static hosting (Block C3) | |
| 220 | app.route("/", pagesRoutes); | |
| 221 | ||
| 222 | // Environments with protected approvals (Block C4) | |
| 223 | app.route("/", environmentsRoutes); | |
| 224 | ||
| 3cbe3d6 | 225 | // AI-native features (Block D) |
| 226 | app.route("/", aiExplainRoutes); // D6 — /:owner/:repo/explain | |
| 227 | app.route("/", aiChangelogRoutes); // D7 — /:owner/:repo/ai/changelog | |
| 228 | app.route("/", copilotRoutes); // D9 — /api/copilot/completions | |
| 229 | app.route("/", depUpdaterRoutes); // D2 — /:owner/:repo/settings/dep-updater | |
| 230 | app.route("/", semanticSearchRoutes); // D1 — /:owner/:repo/search/semantic | |
| 1e162a8 | 231 | app.route("/", aiTestsRoutes); // D8 — /:owner/:repo/ai/tests |
| 232 | app.route("/", discussionRoutes); // E2 — /:owner/:repo/discussions | |
| 233 | app.route("/", gistRoutes); // E4 — /gists, /gists/:slug, /:user/gists | |
| 234 | app.route("/", projectRoutes); // E1 — /:owner/:repo/projects | |
| 235 | app.route("/", wikiRoutes); // E3 — /:owner/:repo/wiki | |
| a79a9ed | 236 | app.route("/", mergeQueueRoutes); // E5 — /:owner/:repo/queue |
| 237 | app.route("/", requiredChecksRoutes); // E6 — /:owner/:repo/gates/protection/:id/checks | |
| 238 | app.route("/", protectedTagsRoutes); // E7 — /:owner/:repo/settings/protected-tags | |
| 8f50ed0 | 239 | app.route("/", trafficRoutes); // F1 — /:owner/:repo/traffic |
| 240 | app.route("/", orgInsightsRoutes); // F2 — /orgs/:slug/insights | |
| 241 | app.route("/", adminRoutes); // F3 — /admin | |
| 242 | app.route("/", billingRoutes); // F4 — /settings/billing + /admin/billing | |
| 3cbe3d6 | 243 | |
| eae38d1 | 244 | // PWA — manifest + service worker + icon (Block G1) |
| 245 | app.route("/", pwaRoutes); | |
| 246 | ||
| 247 | // GraphQL mirror of REST (Block G2) | |
| 248 | app.route("/", graphqlRoutes); | |
| 249 | ||
| 06139e6 | 250 | // Marketplace + app installations + bot identities (Block H1 + H2) |
| 251 | app.route("/", marketplaceRoutes); | |
| 252 | ||
| 71cd5ec | 253 | // Template repositories — POST /:owner/:repo/use-template (Block I2) |
| 254 | app.route("/", templatesRoutes); | |
| 255 | ||
| 08420cd | 256 | // Code scanning UI — /:owner/:repo/security (Block I5) |
| 257 | app.route("/", codeScanningRoutes); | |
| 258 | ||
| 259 | // Sponsors — /sponsors/:user + /settings/sponsors (Block I6) | |
| 260 | app.route("/", sponsorsRoutes); | |
| 261 | ||
| 4c8f666 | 262 | // Symbol / xref navigation — /:owner/:repo/symbols (Block I8) |
| 263 | app.route("/", symbolsRoutes); | |
| 264 | ||
| 4a0dea1 | 265 | // Repository mirroring — /:owner/:repo/settings/mirror (Block I9) |
| 266 | app.route("/", mirrorsRoutes); | |
| 267 | ||
| edf7c36 | 268 | // Enterprise SSO via OIDC — /admin/sso + /login/sso (Block I10) |
| 269 | app.route("/", ssoRoutes); | |
| 270 | ||
| 8098672 | 271 | // Dependency graph — /:owner/:repo/dependencies (Block J1) |
| 272 | app.route("/", depsRoutes); | |
| 273 | ||
| f60ccde | 274 | // Security advisories / dependabot alerts — /:owner/:repo/security/advisories (Block J2) |
| 275 | app.route("/", advisoriesRoutes); | |
| 276 | ||
| 3951454 | 277 | // Commit signature verification / signing keys — /settings/signing-keys (Block J3) |
| 278 | app.route("/", signingKeysRoutes); | |
| 279 | ||
| 7aa8b99 | 280 | // User following + personalised feed (Block J4) |
| 281 | app.route("/", followsRoutes); | |
| 282 | ||
| 9ff7128 | 283 | // Repository rulesets — /:owner/:repo/settings/rulesets (Block J6) |
| 284 | app.route("/", rulesetsRoutes); | |
| 285 | ||
| 0cdfd89 | 286 | // Commit status API — /api/v1/repos/:o/:r/statuses/:sha (Block J8) |
| 287 | app.route("/", commitStatusesRoutes); | |
| 288 | ||
| 3648956 | 289 | // Shields.io-style SVG badges — /:owner/:repo/badge/*.svg (Block J10) |
| 290 | app.route("/", badgesRoutes); | |
| 291 | ||
| f9e7c01 | 292 | // Community profile / health scorecard — /:owner/:repo/community (Block J12) |
| 293 | app.route("/", communityRoutes); | |
| 294 | ||
| 8ec29ff | 295 | // Pinned repositories on user profile — /settings/pins (Block J13) |
| 296 | app.route("/", pinnedReposRoutes); | |
| 297 | ||
| 7c975c6 | 298 | // Repository pulse — /:owner/:repo/pulse (Block J18) |
| 299 | app.route("/", pulseRoutes); | |
| 300 | ||
| 26484eb | 301 | // Atom feeds — /:owner/:repo/{commits,releases,issues}.atom (Block J19) |
| 302 | app.route("/", feedRoutes); | |
| 303 | ||
| f3e1844 | 304 | // CODEOWNERS validator — /:owner/:repo/codeowners (Block J21) |
| 305 | app.route("/", codeownersLintRoutes); | |
| 306 | ||
| 7c0203e | 307 | // Code review suggestion blocks — apply ```suggestion fences to head branch (Block J22) |
| 308 | app.route("/", codeSuggestionsRoutes); | |
| 309 | ||
| d6daf49 | 310 | // Branch rename — owner-only /:owner/:repo/settings/branches (Block J24) |
| 311 | app.route("/", branchRenameRoutes); | |
| 312 | ||
| 9090df3 | 313 | // Time-to-first-response metric — /:owner/:repo/insights/response-time (Block J25) |
| 314 | // Must be mounted BEFORE insightsRoutes so the static `/insights/response-time` | |
| 315 | // path wins over any future `/insights/:id` dynamic route that might appear. | |
| 316 | app.route("/", responseTimeRoutes); | |
| 317 | ||
| c02a55b | 318 | // Branch staleness / age report — /:owner/:repo/branches/age (Block J27) |
| 319 | // Must be mounted BEFORE webRoutes so the static `/branches/age` path wins | |
| 320 | // over the `/:owner/:repo/tree/:branch` dynamic web catch-all. | |
| 321 | app.route("/", branchAgeRoutes); | |
| 322 | ||
| 8c5346c | 323 | // PR lead-time metric — /:owner/:repo/insights/lead-time (Block J29) |
| 324 | // Mounted alongside response-time before insightsRoutes. | |
| 325 | app.route("/", prLeadTimeRoutes); | |
| 326 | ||
| 07efa08 | 327 | // Repository language breakdown — /:owner/:repo/languages (Block J30) |
| 328 | app.route("/", languageRoutes); | |
| 329 | ||
| ce08e97 | 330 | // Repository size audit — /:owner/:repo/insights/size (Block J31) |
| 331 | // Must be mounted BEFORE insightsRoutes so the static `/insights/size` path | |
| 332 | // wins over any future dynamic `/insights/:id` route. | |
| 333 | app.route("/", repoSizeRoutes); | |
| 334 | ||
| 28bc555 | 335 | // PR size distribution — /:owner/:repo/insights/pr-size (Block J32) |
| 336 | app.route("/", prSizeRoutes); | |
| 337 | ||
| 3ef4c9d | 338 | // Insights + milestones |
| 339 | app.route("/", insightsRoutes); | |
| 340 | ||
| c81ab7a | 341 | // Explore page |
| 342 | app.route("/", exploreRoutes); | |
| 343 | ||
| 79136bb | 344 | // Web UI (catch-all, must be last) |
| 345 | app.route("/", webRoutes); | |
| 346 | ||
| 347 | // Global 404 | |
| 348 | app.notFound((c) => { | |
| 349 | return c.html( | |
| 350 | <Layout title="Not Found"> | |
| 351 | <div class="empty-state"> | |
| 352 | <h2>404</h2> | |
| 353 | <p>Page not found.</p> | |
| 354 | <a href="/" style="margin-top: 12px; display: inline-block"> | |
| 355 | Go home | |
| 356 | </a> | |
| 357 | </div> | |
| 358 | </Layout>, | |
| 359 | 404 | |
| 360 | ); | |
| 361 | }); | |
| 362 | ||
| 363 | // Global error handler | |
| 364 | app.onError((err, c) => { | |
| 365 | console.error("[error]", err); | |
| 366 | return c.html( | |
| 367 | <Layout title="Error"> | |
| 368 | <div class="empty-state"> | |
| 369 | <h2>Something went wrong</h2> | |
| 370 | <p>An unexpected error occurred.</p> | |
| 371 | {process.env.NODE_ENV !== "production" && ( | |
| 372 | <pre style="margin-top: 16px; text-align: left; font-size: 12px; color: var(--red)"> | |
| 373 | {err.message} | |
| 374 | </pre> | |
| 375 | )} | |
| 376 | </div> | |
| 377 | </Layout>, | |
| 378 | 500 | |
| 379 | ); | |
| 380 | }); | |
| 381 | ||
| 382 | export default app; |