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