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