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