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"; |
| c63b860 | 5 | // BLOCK O2 — shared error-page surface (404 / 500 / 403). |
| 6 | import { NotFoundPage, ServerErrorPage } from "./views/error-page"; | |
| 80bed05 | 7 | import { reportError } from "./lib/observability"; |
| 3ef4c9d | 8 | import { requestContext } from "./middleware/request-context"; |
| 9 | import { rateLimit } from "./middleware/rate-limit"; | |
| 79136bb | 10 | import gitRoutes from "./routes/git"; |
| 11 | import apiRoutes from "./routes/api"; | |
| 45e31d0 | 12 | import apiV2Routes from "./routes/api-v2"; |
| 13 | import apiDocsRoutes from "./routes/api-docs"; | |
| 79136bb | 14 | import authRoutes from "./routes/auth"; |
| c63b860 | 15 | import passwordResetRoutes from "./routes/password-reset"; |
| 16 | import emailVerificationRoutes from "./routes/email-verification"; | |
| cd4f63b | 17 | import magicLinkRoutes from "./routes/magic-link"; |
| 79136bb | 18 | import settingsRoutes from "./routes/settings"; |
| 7298a17 | 19 | import settings2faRoutes from "./routes/settings-2fa"; |
| 79136bb | 20 | import issueRoutes from "./routes/issues"; |
| 21 | import repoSettings from "./routes/repo-settings"; | |
| 23d1a81 | 22 | import collaboratorRoutes from "./routes/collaborators"; |
| 04f6b7f | 23 | import teamCollaboratorRoutes from "./routes/team-collaborators"; |
| 24 | import invitesRoutes from "./routes/invites"; | |
| 25 | import liveEventsRoutes from "./routes/live-events"; | |
| 79136bb | 26 | import compareRoutes from "./routes/compare"; |
| 0074234 | 27 | import pullRoutes from "./routes/pulls"; |
| 28 | import editorRoutes from "./routes/editor"; | |
| c81ab7a | 29 | import forkRoutes from "./routes/fork"; |
| 30 | import webhookRoutes from "./routes/webhooks"; | |
| 31 | import exploreRoutes from "./routes/explore"; | |
| 32 | import tokenRoutes from "./routes/tokens"; | |
| 43de941 | 33 | import contributorRoutes from "./routes/contributors"; |
| 699e5c7 | 34 | import healthRoutes from "./routes/health-probe"; |
| 35 | import healthDashboardRoutes from "./routes/health"; | |
| 2316be6 | 36 | import statusRoutes from "./routes/status"; |
| b1be050 | 37 | import adminStatusRoutes from "./routes/admin-status"; |
| 80bed05 | 38 | import helpRoutes from "./routes/help"; |
| b0148e9 | 39 | import marketingRoutes from "./routes/marketing"; |
| 5f2e749 | 40 | import pricingRoutes from "./routes/pricing"; |
| 5618f9a | 41 | import seoRoutes from "./routes/seo"; |
| 05cdb85 | 42 | import versionRoutes from "./routes/version"; |
| f295f78 | 43 | import { platformStatus } from "./routes/platform-status"; |
| 52ad8b1 | 44 | import publicStatsRoutes from "./routes/public-stats"; |
| 45 | import demoRoutes from "./routes/demo"; | |
| 16b325c | 46 | import insightRoutes from "./routes/insights"; |
| f1ab587 | 47 | import dashboardRoutes from "./routes/dashboard"; |
| 36b4cbd | 48 | import legalRoutes from "./routes/legal"; |
| bdbd0de | 49 | import importRoutes from "./routes/import"; |
| 14c3cc8 | 50 | import importBulkRoutes from "./routes/import-bulk"; |
| f390cfa | 51 | import importSecretsRoutes from "./routes/import-secrets"; |
| 14c3cc8 | 52 | import migrationRoutes from "./routes/migrations"; |
| 53 | import specsRoutes from "./routes/specs"; | |
| 79136bb | 54 | import webRoutes from "./routes/web"; |
| 0316dbb | 55 | import hookRoutes from "./routes/hooks"; |
| 56 | import eventsRoutes from "./routes/events"; | |
| 57 | import passkeyRoutes from "./routes/passkeys"; | |
| 58 | import oauthRoutes from "./routes/oauth"; | |
| 59 | import developerAppsRoutes from "./routes/developer-apps"; | |
| 60 | import themeRoutes from "./routes/theme"; | |
| 61 | import auditRoutes from "./routes/audit"; | |
| 62 | import reactionRoutes from "./routes/reactions"; | |
| 63 | import savedReplyRoutes from "./routes/saved-replies"; | |
| 64 | import deploymentRoutes from "./routes/deployments"; | |
| 65 | import orgRoutes from "./routes/orgs"; | |
| 66 | import notificationRoutes from "./routes/notifications"; | |
| 67 | import onboardingRoutes from "./routes/onboarding"; | |
| 68 | import adminRoutes from "./routes/admin"; | |
| f764c07 | 69 | import adminDeploysRoutes from "./routes/admin-deploys"; |
| 70 | import adminDeploysPageRoutes from "./routes/admin-deploys-page"; | |
| 9dd96b9 | 71 | import adminOpsRoutes from "./routes/admin-ops"; |
| f2c00b4 | 72 | import adminSelfHostRoutes from "./routes/admin-self-host"; |
| 826eccf | 73 | import adminDiagnoseRoutes from "./routes/admin-diagnose"; |
| 509c376 | 74 | import adminIntegrationsRoutes from "./routes/admin-integrations"; |
| 0316dbb | 75 | import advisoriesRoutes from "./routes/advisories"; |
| 76 | import aiChangelogRoutes from "./routes/ai-changelog"; | |
| 77 | import aiExplainRoutes from "./routes/ai-explain"; | |
| 78 | import aiTestsRoutes from "./routes/ai-tests"; | |
| 79 | import askRoutes from "./routes/ask"; | |
| 80 | import billingRoutes from "./routes/billing"; | |
| 6778ad2 | 81 | import stripeWebhookRoutes from "./routes/stripe-webhook"; |
| 0316dbb | 82 | import codeScanningRoutes from "./routes/code-scanning"; |
| 83 | import commitStatusesRoutes from "./routes/commit-statuses"; | |
| 84 | import copilotRoutes from "./routes/copilot"; | |
| 85 | import depUpdaterRoutes from "./routes/dep-updater"; | |
| 86 | import depsRoutes from "./routes/deps"; | |
| 87 | import discussionsRoutes from "./routes/discussions"; | |
| 88 | import environmentsRoutes from "./routes/environments"; | |
| 89 | import followsRoutes from "./routes/follows"; | |
| 90 | import gatesRoutes from "./routes/gates"; | |
| 91 | import gistsRoutes from "./routes/gists"; | |
| 92 | import graphqlRoutes from "./routes/graphql"; | |
| 2c2163e | 93 | import mcpRoutes from "./routes/mcp"; |
| 0316dbb | 94 | import marketplaceRoutes from "./routes/marketplace"; |
| 95 | import mergeQueueRoutes from "./routes/merge-queue"; | |
| 96 | import mirrorsRoutes from "./routes/mirrors"; | |
| 97 | import orgInsightsRoutes from "./routes/org-insights"; | |
| 98 | import packagesRoutes from "./routes/packages"; | |
| 99 | import packagesApiRoutes from "./routes/packages-api"; | |
| 100 | import pagesRoutes from "./routes/pages"; | |
| 101 | import projectsRoutes from "./routes/projects"; | |
| 102 | import protectedTagsRoutes from "./routes/protected-tags"; | |
| 103 | import pwaRoutes from "./routes/pwa"; | |
| 46d6165 | 104 | import installRoutes from "./routes/install"; |
| cd4f63b | 105 | import dxtRoutes from "./routes/dxt"; |
| 662ce86 | 106 | import connectClaudeRoutes from "./routes/connect-claude"; |
| 0316dbb | 107 | import releasesRoutes from "./routes/releases"; |
| 108 | import requiredChecksRoutes from "./routes/required-checks"; | |
| 109 | import rulesetsRoutes from "./routes/rulesets"; | |
| 110 | import searchRoutes from "./routes/search"; | |
| 111 | import semanticSearchRoutes from "./routes/semantic-search"; | |
| 112 | import signingKeysRoutes from "./routes/signing-keys"; | |
| 113 | import sponsorsRoutes from "./routes/sponsors"; | |
| 114 | import ssoRoutes from "./routes/sso"; | |
| 46d6165 | 115 | import githubOauthRoutes from "./routes/github-oauth"; |
| 582cdac | 116 | import googleOauthRoutes from "./routes/google-oauth"; |
| 0316dbb | 117 | import symbolsRoutes from "./routes/symbols"; |
| 118 | import templatesRoutes from "./routes/templates"; | |
| 119 | import trafficRoutes from "./routes/traffic"; | |
| 120 | import wikisRoutes from "./routes/wikis"; | |
| 121 | import workflowsRoutes from "./routes/workflows"; | |
| 5ff9cc2 | 122 | import workflowArtifactsRoutes from "./routes/workflow-artifacts"; |
| 123 | import workflowSecretsRoutes from "./routes/workflow-secrets"; | |
| 46d6165 | 124 | import sleepModeRoutes from "./routes/sleep-mode"; |
| 52ad8b1 | 125 | import vsGithubRoutes from "./routes/vs-github"; |
| cd4f63b | 126 | import playgroundRoutes from "./routes/playground"; |
| 59b6fb2 | 127 | import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit"; |
| 128 | import { csrfToken, csrfProtect } from "./middleware/csrf"; | |
| 79136bb | 129 | |
| 2316901 | 130 | import type { AuthEnv } from "./middleware/auth"; |
| bf19c50 | 131 | import { softAuth } from "./middleware/auth"; |
| 2316901 | 132 | |
| 133 | const app = new Hono<AuthEnv>(); | |
| 79136bb | 134 | |
| 3ef4c9d | 135 | // Request context (request ID, start time) runs before everything else |
| 136 | app.use("*", requestContext); | |
| 05b973e | 137 | // Middleware — compression first (wraps all responses) |
| 138 | app.use("*", compress()); | |
| 139 | // Logger only on non-git routes to avoid overhead on clone/push | |
| 140 | app.use("*", async (c, next) => { | |
| 141 | if (c.req.path.includes(".git/")) return next(); | |
| 142 | return logger()(c, next); | |
| 143 | }); | |
| 79136bb | 144 | app.use("/api/*", cors()); |
| bf19c50 | 145 | // Global softAuth — populates c.get("user") for every downstream middleware |
| 146 | // + route. This was previously per-route, which meant rate-limit middleware | |
| 147 | // (and anything else inspecting auth state) always saw a null user. Keep | |
| 148 | // individual routes free to add requireAuth on top for hard gating; this | |
| 149 | // just establishes the user object cheaply. | |
| 150 | app.use("*", softAuth); | |
| 290ea77 | 151 | |
| 36cc17a | 152 | // Force-revalidate HTML on every request — kills browser cache holding stale |
| 290ea77 | 153 | // pre-redesign markup. JSON / static assets keep their own cache rules; only |
| 154 | // text/html responses get the no-cache stamp. Without this, every push to | |
| 155 | // main left users staring at cached 80s-looking pages from before the design | |
| 156 | // landed. | |
| 36cc17a | 157 | // |
| 158 | // We deliberately use `private, no-cache, must-revalidate` rather than | |
| 159 | // `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache), | |
| 160 | // which makes every Back/Forward press a cold server round-trip — that | |
| 161 | // contributed to the "every nav feels like a fresh login" UX complaint. | |
| 162 | // `no-cache` still revalidates on direct fetch but lets bfcache hold the | |
| 163 | // page in memory between navigations. | |
| 290ea77 | 164 | app.use("*", async (c, next) => { |
| 165 | await next(); | |
| 166 | const ct = c.res.headers.get("content-type") || ""; | |
| 167 | if (ct.startsWith("text/html")) { | |
| 36cc17a | 168 | c.header("cache-control", "private, no-cache, must-revalidate"); |
| 290ea77 | 169 | } |
| 170 | }); | |
| 826eccf | 171 | // Rate-limit API + auth endpoints. |
| 172 | // | |
| a41e675 | 173 | // `/api/*`: 1000/min per IP — generous so an admin clicking around the |
| 174 | // operator console (or a CDN/proxy concentrating multiple users behind one | |
| 175 | // IP) doesn't hit the wall. Bot-resistant headroom comes from the auth | |
| 176 | // rate limits below, not this one. | |
| 177 | // | |
| 178 | // `authedMultiplier` is set but only fires when an upstream middleware has | |
| 179 | // already populated c.get("user") — most app.use() chains apply softAuth | |
| 180 | // per-route, so the multiplier is best-effort. Keep the anonymous base | |
| 181 | // high enough that humans never feel it. | |
| 182 | // | |
| 183 | // Skip-paths: dashboard plumbing endpoints that the layout polls on a | |
| 184 | // fixed cadence and that we don't want consuming any bucket: | |
| 185 | // /api/version — layout polls every 15s | |
| 826eccf | 186 | // /api/notifications/count — nav bell unread-count fetcher |
| 187 | // /pwa/vapid-public-key — fetched once per push-notification opt-in | |
| 188 | app.use( | |
| 189 | "/api/*", | |
| a41e675 | 190 | rateLimit(1000, 60_000, "api", { |
| 826eccf | 191 | authedMultiplier: 4, |
| 192 | skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"], | |
| 193 | }) | |
| 194 | ); | |
| 0316dbb | 195 | app.use("/login", rateLimit(20, 60_000, "login")); |
| 196 | app.use("/register", rateLimit(10, 60_000, "register")); | |
| c63b860 | 197 | // BLOCK P1 — throttle forgot-password to deter enumeration + mail spam. |
| 198 | app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password")); | |
| cd4f63b | 199 | // BLOCK Q2 — throttle magic-link sign-in for the same reason. |
| 200 | app.use("/login/magic", rateLimit(5, 60_000, "magic-link")); | |
| 79136bb | 201 | |
| 59b6fb2 | 202 | // CSRF protection — set token on all requests, validate on mutations |
| 203 | app.use("*", csrfToken); | |
| 204 | app.use("*", csrfProtect); | |
| 205 | ||
| 45e31d0 | 206 | // Rate limit auth routes |
| 207 | app.use("/login", authRateLimit); | |
| 208 | app.use("/register", authRateLimit); | |
| 209 | ||
| 59b6fb2 | 210 | // Rate limit git operations |
| 211 | app.use("/:owner/:repo.git/*", gitRateLimit); | |
| 212 | ||
| 213 | // Rate limit search | |
| 214 | app.use("/:owner/:repo/search", searchRateLimit); | |
| 215 | app.use("/explore", searchRateLimit); | |
| 79136bb | 216 | |
| 217 | // Git Smart HTTP protocol routes (must be before web routes) | |
| 218 | app.route("/", gitRoutes); | |
| 219 | ||
| 45e31d0 | 220 | // REST API v1 (legacy) |
| 79136bb | 221 | app.route("/", apiRoutes); |
| 222 | ||
| 52ad8b1 | 223 | // Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE |
| 224 | // apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base | |
| 225 | // router's catch-shape, and BEFORE adminRoutes so the live /demo page | |
| 226 | // wins over the legacy /demo redirect in src/routes/admin.tsx. | |
| 227 | app.route("/", demoRoutes); | |
| 228 | ||
| 0316dbb | 229 | // REST API v2 (basePath /api/v2) |
| 230 | app.route("/", apiV2Routes); | |
| 231 | ||
| ad6d4ad | 232 | // Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs) |
| 233 | app.route("/", hookRoutes); | |
| 21f8dbd | 234 | app.route("/api/events", eventsRoutes); |
| ad6d4ad | 235 | |
| 45e31d0 | 236 | // API documentation |
| 237 | app.route("/", apiDocsRoutes); | |
| 79136bb | 238 | |
| 239 | // Auth routes (register, login, logout) | |
| 240 | app.route("/", authRoutes); | |
| 241 | ||
| c63b860 | 242 | // BLOCK P1 — Password reset (forgot-password + reset-password) |
| 243 | app.route("/", passwordResetRoutes); | |
| 244 | ||
| 245 | // BLOCK P2 — Email verification (verify-email + resend) | |
| 246 | app.route("/", emailVerificationRoutes); | |
| 247 | ||
| cd4f63b | 248 | // BLOCK Q2 — Magic-link sign-in (/login/magic + callback) |
| 249 | app.route("/", magicLinkRoutes); | |
| 250 | ||
| 79136bb | 251 | // Settings routes (profile, SSH keys) |
| 252 | app.route("/", settingsRoutes); | |
| 253 | ||
| 7298a17 | 254 | // 2FA / TOTP settings (Block B4) |
| 255 | app.route("/", settings2faRoutes); | |
| 256 | ||
| 2df1f8c | 257 | // WebAuthn / passkey routes (Block B5) |
| 258 | app.route("/", passkeyRoutes); | |
| 259 | ||
| 058d752 | 260 | // OAuth 2.0 provider (Block B6) |
| 261 | app.route("/", oauthRoutes); | |
| 262 | app.route("/", developerAppsRoutes); | |
| 263 | ||
| 6fc53bd | 264 | // Theme toggle (dark/light cookie) |
| 265 | app.route("/", themeRoutes); | |
| 266 | ||
| 267 | // Audit log UI | |
| 268 | app.route("/", auditRoutes); | |
| 269 | ||
| 270 | // Reactions API (issues, PRs, comments) | |
| 271 | app.route("/", reactionRoutes); | |
| 272 | ||
| 24cf2ca | 273 | // Saved replies (per-user canned comment templates) |
| 274 | app.route("/", savedReplyRoutes); | |
| 275 | ||
| 276 | // Environments + deployment history UI | |
| 277 | app.route("/", deploymentRoutes); | |
| 278 | ||
| 6563f0a | 279 | // Organizations + teams (Block B1) |
| 280 | app.route("/", orgRoutes); | |
| 281 | ||
| c81ab7a | 282 | // API tokens |
| 283 | app.route("/", tokenRoutes); | |
| 284 | ||
| 59b6fb2 | 285 | // Notifications |
| 3ef4c9d | 286 | app.route("/", notificationRoutes); |
| 287 | ||
| 79136bb | 288 | // Repo settings (description, visibility, delete) |
| 289 | app.route("/", repoSettings); | |
| 290 | ||
| 23d1a81 | 291 | // Repo collaborators (add/list/remove) |
| 292 | app.route("/", collaboratorRoutes); | |
| 293 | ||
| 04f6b7f | 294 | // Team-based repo collaborators (invite a whole team) |
| 295 | app.route("/", teamCollaboratorRoutes); | |
| 296 | ||
| 297 | // Collaborator invite accept flow (token-based) | |
| 298 | app.route("/", invitesRoutes); | |
| 299 | ||
| 300 | // Real-time SSE endpoint (topic-based live updates) | |
| 301 | app.route("/", liveEventsRoutes); | |
| 302 | ||
| c81ab7a | 303 | // Webhooks management |
| 304 | app.route("/", webhookRoutes); | |
| 305 | ||
| 79136bb | 306 | // Compare view (branch diffs) |
| 307 | app.route("/", compareRoutes); | |
| 308 | ||
| 309 | // Issue tracker | |
| 310 | app.route("/", issueRoutes); | |
| 311 | ||
| 0074234 | 312 | // Pull requests |
| 313 | app.route("/", pullRoutes); | |
| 314 | ||
| c81ab7a | 315 | // Fork |
| 316 | app.route("/", forkRoutes); | |
| 317 | ||
| 0074234 | 318 | // Web file editor |
| 319 | app.route("/", editorRoutes); | |
| 320 | ||
| 43de941 | 321 | // Contributors |
| 322 | app.route("/", contributorRoutes); | |
| 323 | ||
| 699e5c7 | 324 | // Health liveness + metrics endpoints |
| 2c34075 | 325 | app.route("/", healthRoutes); |
| 326 | ||
| f295f78 | 327 | // Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md) |
| 328 | app.route("/api/platform-status", platformStatus); | |
| 329 | ||
| 52ad8b1 | 330 | // Block L4 — Public stats counters (powers landing-page social proof) |
| 331 | app.route("/", publicStatsRoutes); | |
| 332 | ||
| 333 | // Block L3 — Live /demo page + /api/v2/demo/* endpoints | |
| 334 | app.route("/", demoRoutes); | |
| 335 | ||
| 2316be6 | 336 | // Public /status — human-readable platform health page |
| 337 | app.route("/", statusRoutes); | |
| 338 | ||
| b1be050 | 339 | // BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status). |
| 340 | // Mounted near the public status route so the two surfaces are visible | |
| 341 | // side-by-side; routes are gated by isSiteAdmin internally. | |
| 342 | app.route("/", adminStatusRoutes); | |
| 343 | ||
| 80bed05 | 344 | // /help — quickstart + API cheatsheet |
| 345 | app.route("/", helpRoutes); | |
| 346 | ||
| 5f2e749 | 347 | // L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing |
| 348 | // so the new editorial pricing layout wins the route; the legacy marketing | |
| 349 | // pricing remains as a safety net but is shadowed at the router. | |
| 350 | app.route("/", pricingRoutes); | |
| 351 | ||
| b0148e9 | 352 | // /pricing, /features, /about — marketing surface |
| 353 | app.route("/", marketingRoutes); | |
| 354 | ||
| 5618f9a | 355 | // SEO: robots.txt + sitemap.xml |
| 356 | app.route("/", seoRoutes); | |
| 357 | ||
| 05cdb85 | 358 | // /api/version — live build SHA + uptime; client poller uses this to |
| 359 | // surface 'New version available — reload' banners on deploy. | |
| 360 | app.route("/", versionRoutes); | |
| 361 | ||
| 699e5c7 | 362 | // Health dashboard (per-repo health page) |
| 363 | app.route("/", healthDashboardRoutes); | |
| 364 | ||
| 9dd96b9 | 365 | // Block R1 — site-admin operations console. MUST be mounted BEFORE |
| 366 | // insightRoutes because its POST `/:owner/:repo/rollback` catch-all would | |
| 367 | // otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops). | |
| 368 | app.route("/", adminOpsRoutes); | |
| f2c00b4 | 369 | // BLOCK W — Self-host status + bootstrap dashboard. |
| 370 | app.route("/", adminSelfHostRoutes); | |
| 826eccf | 371 | // BLOCK X — AI health-scan diagnose page (/admin/diagnose). |
| 372 | app.route("/", adminDiagnoseRoutes); | |
| 9dd96b9 | 373 | |
| 16b325c | 374 | // Insights (time-travel, dependencies, rollback) |
| 375 | app.route("/", insightRoutes); | |
| 376 | ||
| f1ab587 | 377 | // Command center dashboard |
| 378 | app.route("/", dashboardRoutes); | |
| 379 | ||
| 36b4cbd | 380 | // Legal pages (terms, privacy, AUP) |
| 381 | app.route("/", legalRoutes); | |
| 382 | ||
| bdbd0de | 383 | // GitHub import / migration |
| 384 | app.route("/", importRoutes); | |
| 14c3cc8 | 385 | app.route("/", importBulkRoutes); |
| f390cfa | 386 | app.route("/", importSecretsRoutes); |
| 14c3cc8 | 387 | app.route("/", migrationRoutes); |
| 388 | ||
| 389 | // Spec-to-PR (experimental AI-generated draft PRs) | |
| 390 | app.route("/", specsRoutes); | |
| bdbd0de | 391 | |
| c81ab7a | 392 | // Explore page |
| 393 | app.route("/", exploreRoutes); | |
| 394 | ||
| 59b6fb2 | 395 | // Onboarding |
| 396 | app.route("/", onboardingRoutes); | |
| 397 | ||
| 0316dbb | 398 | // Admin + feature routes |
| 399 | app.route("/", adminRoutes); | |
| 509c376 | 400 | app.route("/", adminIntegrationsRoutes); |
| f764c07 | 401 | app.route("/", adminDeploysRoutes); |
| 402 | app.route("/", adminDeploysPageRoutes); | |
| 9dd96b9 | 403 | // Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above. |
| 0316dbb | 404 | app.route("/", advisoriesRoutes); |
| 405 | app.route("/", aiChangelogRoutes); | |
| 406 | app.route("/", aiExplainRoutes); | |
| 407 | app.route("/", aiTestsRoutes); | |
| 408 | app.route("/", askRoutes); | |
| 409 | app.route("/", billingRoutes); | |
| 6778ad2 | 410 | app.route("/", stripeWebhookRoutes); |
| 0316dbb | 411 | app.route("/", codeScanningRoutes); |
| 412 | app.route("/", commitStatusesRoutes); | |
| 413 | app.route("/", copilotRoutes); | |
| 414 | app.route("/", depUpdaterRoutes); | |
| 415 | app.route("/", depsRoutes); | |
| 416 | app.route("/", discussionsRoutes); | |
| 417 | app.route("/", environmentsRoutes); | |
| 418 | app.route("/", followsRoutes); | |
| 419 | app.route("/", gatesRoutes); | |
| 420 | app.route("/", gistsRoutes); | |
| 421 | app.route("/", graphqlRoutes); | |
| 2c2163e | 422 | app.route("/", mcpRoutes); |
| 0316dbb | 423 | app.route("/", marketplaceRoutes); |
| 424 | app.route("/", mergeQueueRoutes); | |
| 425 | app.route("/", mirrorsRoutes); | |
| 426 | app.route("/", orgInsightsRoutes); | |
| 427 | app.route("/", packagesRoutes); | |
| 428 | app.route("/", packagesApiRoutes); | |
| 429 | app.route("/", pagesRoutes); | |
| 430 | app.route("/", projectsRoutes); | |
| 431 | app.route("/", protectedTagsRoutes); | |
| 432 | app.route("/", pwaRoutes); | |
| 46d6165 | 433 | app.route("/", installRoutes); |
| cd4f63b | 434 | // BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension) |
| 435 | app.route("/", dxtRoutes); | |
| 662ce86 | 436 | // Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted |
| 437 | // next to the other one-click flows (install.sh + .dxt) for surface symmetry. | |
| 438 | app.route("/", connectClaudeRoutes); | |
| 0316dbb | 439 | app.route("/", releasesRoutes); |
| 440 | app.route("/", requiredChecksRoutes); | |
| 441 | app.route("/", rulesetsRoutes); | |
| 442 | app.route("/", searchRoutes); | |
| 443 | app.route("/", semanticSearchRoutes); | |
| 444 | app.route("/", signingKeysRoutes); | |
| 445 | app.route("/", sponsorsRoutes); | |
| 446 | app.route("/", ssoRoutes); | |
| 46d6165 | 447 | app.route("/", githubOauthRoutes); |
| 582cdac | 448 | app.route("/", googleOauthRoutes); |
| 0316dbb | 449 | app.route("/", symbolsRoutes); |
| 450 | app.route("/", templatesRoutes); | |
| 451 | app.route("/", trafficRoutes); | |
| 452 | app.route("/", wikisRoutes); | |
| 453 | app.route("/", workflowsRoutes); | |
| 5ff9cc2 | 454 | app.route("/", workflowArtifactsRoutes); |
| 455 | app.route("/", workflowSecretsRoutes); | |
| 46d6165 | 456 | app.route("/", sleepModeRoutes); |
| 52ad8b1 | 457 | app.route("/", vsGithubRoutes); |
| 0316dbb | 458 | |
| cd4f63b | 459 | // Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted |
| 460 | // before the web catch-all so the bare `/play` literal wins over the | |
| 461 | // `/:owner` user-profile route. | |
| 462 | app.route("/", playgroundRoutes); | |
| 463 | ||
| 79136bb | 464 | // Web UI (catch-all, must be last) |
| 465 | app.route("/", webRoutes); | |
| 466 | ||
| c63b860 | 467 | // Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so |
| 468 | // the markup stays consistent with /500 and the admin /403 page. | |
| 79136bb | 469 | app.notFound((c) => { |
| 36cc17a | 470 | const user = c.get("user") ?? null; |
| 79136bb | 471 | return c.html( |
| c63b860 | 472 | <NotFoundPage user={user} method={c.req.method} path={c.req.path} />, |
| 79136bb | 473 | 404 |
| 474 | ); | |
| 475 | }); | |
| 476 | ||
| c63b860 | 477 | // Global error handler — BLOCK O2 uses the shared `ServerErrorPage` |
| 478 | // view. Trace block only shown outside production. | |
| 79136bb | 479 | app.onError((err, c) => { |
| 80bed05 | 480 | reportError(err, { |
| 481 | requestId: c.get("requestId"), | |
| 482 | path: c.req.path, | |
| 483 | method: c.req.method, | |
| 484 | }); | |
| c63b860 | 485 | // Prefer the inbound `x-request-id` header (LB-supplied) and fall |
| 486 | // back to the context value set by request-context middleware. | |
| 487 | const requestId = | |
| 488 | c.req.header("x-request-id") || | |
| 489 | ((c.get("requestId" as never) as string | undefined) ?? undefined); | |
| 36cc17a | 490 | const user = c.get("user") ?? null; |
| c63b860 | 491 | const trace = |
| 492 | process.env.NODE_ENV !== "production" && err && err.message | |
| 493 | ? err.message | |
| 494 | : undefined; | |
| 79136bb | 495 | return c.html( |
| c63b860 | 496 | <ServerErrorPage user={user} requestId={requestId} trace={trace} />, |
| 79136bb | 497 | 500 |
| 498 | ); | |
| 499 | }); | |
| 500 | ||
| 501 | export default app; |