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