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