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