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