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