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