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"; | |
| cc34156 | 19 | import digestRoutes from "./routes/digest"; |
| e9aa4d8 | 20 | import activityRoutes from "./routes/activity"; |
| 79136bb | 21 | import authRoutes from "./routes/auth"; |
| c63b860 | 22 | import passwordResetRoutes from "./routes/password-reset"; |
| 23 | import emailVerificationRoutes from "./routes/email-verification"; | |
| cd4f63b | 24 | import magicLinkRoutes from "./routes/magic-link"; |
| 79136bb | 25 | import settingsRoutes from "./routes/settings"; |
| 7298a17 | 26 | import settings2faRoutes from "./routes/settings-2fa"; |
| e75eddc | 27 | import settingsAgentsRoutes from "./routes/settings-agents"; |
| 1d4ff60 | 28 | import settingsIntegrationsRoutes from "./routes/settings-integrations"; |
| 29 | import integrationsChatRoutes from "./routes/integrations-chat"; | |
| e75eddc | 30 | import agentsRoutes from "./routes/agents"; |
| ef3fd93 | 31 | import agentPipelinesRoutes from "./routes/agent-pipelines"; |
| 79136bb | 32 | import issueRoutes from "./routes/issues"; |
| 85c4e13 | 33 | import milestonesRoutes from "./routes/milestones"; |
| f928118 | 34 | import shipAgentRoutes from "./routes/ship-agent"; |
| cb5a796 | 35 | import commentModerationRoutes from "./routes/comment-moderation"; |
| 79136bb | 36 | import repoSettings from "./routes/repo-settings"; |
| 479dcd9 | 37 | import automationSettingsRoutes from "./routes/automation-settings"; |
| 23d1a81 | 38 | import collaboratorRoutes from "./routes/collaborators"; |
| 04f6b7f | 39 | import teamCollaboratorRoutes from "./routes/team-collaborators"; |
| 40 | import invitesRoutes from "./routes/invites"; | |
| 41 | import liveEventsRoutes from "./routes/live-events"; | |
| 3c03977 | 42 | import prLiveRoutes from "./routes/pr-live"; |
| 79136bb | 43 | import compareRoutes from "./routes/compare"; |
| 0074234 | 44 | import pullRoutes from "./routes/pulls"; |
| 79ed944 | 45 | import prSandboxRoutes from "./routes/pr-sandbox"; |
| 9b3a183 | 46 | import devEnvRoutes from "./routes/dev-env"; |
| 0074234 | 47 | import editorRoutes from "./routes/editor"; |
| 6f2809f | 48 | import aiEditorRoutes from "./routes/ai-editor"; |
| c81ab7a | 49 | import forkRoutes from "./routes/fork"; |
| 50 | import webhookRoutes from "./routes/webhooks"; | |
| 51 | import exploreRoutes from "./routes/explore"; | |
| 52 | import tokenRoutes from "./routes/tokens"; | |
| 43de941 | 53 | import contributorRoutes from "./routes/contributors"; |
| 699e5c7 | 54 | import healthRoutes from "./routes/health-probe"; |
| 55 | import healthDashboardRoutes from "./routes/health"; | |
| 2316be6 | 56 | import statusRoutes from "./routes/status"; |
| b1be050 | 57 | import adminStatusRoutes from "./routes/admin-status"; |
| 80bed05 | 58 | import helpRoutes from "./routes/help"; |
| e1fc7db | 59 | import changelogRoutes from "./routes/changelog"; |
| e0e4219 | 60 | import docsRoutes from "./routes/docs"; |
| b0148e9 | 61 | import marketingRoutes from "./routes/marketing"; |
| 5f2e749 | 62 | import pricingRoutes from "./routes/pricing"; |
| 9f29b65 | 63 | import enterpriseRoutes from "./routes/enterprise"; |
| 5618f9a | 64 | import seoRoutes from "./routes/seo"; |
| 05cdb85 | 65 | import versionRoutes from "./routes/version"; |
| f295f78 | 66 | import { platformStatus } from "./routes/platform-status"; |
| 52ad8b1 | 67 | import publicStatsRoutes from "./routes/public-stats"; |
| 68 | import demoRoutes from "./routes/demo"; | |
| 16b325c | 69 | import insightRoutes from "./routes/insights"; |
| 8286942 | 70 | import engineeringInsightsRoutes from "./routes/engineering-insights"; |
| 8d1483c | 71 | import doraRoutes from "./routes/dora"; |
| f1ab587 | 72 | import dashboardRoutes from "./routes/dashboard"; |
| 36b4cbd | 73 | import legalRoutes from "./routes/legal"; |
| 4b66018 | 74 | import legalDmcaRoutes from "./routes/legal/dmca"; |
| 75 | import legalTermsRoutes from "./routes/legal/terms"; | |
| 76 | import legalPrivacyRoutes from "./routes/legal/privacy"; | |
| 77 | import legalAcceptableUseRoutes from "./routes/legal/acceptable-use"; | |
| bdbd0de | 78 | import importRoutes from "./routes/import"; |
| 14c3cc8 | 79 | import importBulkRoutes from "./routes/import-bulk"; |
| f390cfa | 80 | import importSecretsRoutes from "./routes/import-secrets"; |
| bb2dea9 | 81 | import actionsImporterRoutes from "./routes/actions-importer"; |
| 14c3cc8 | 82 | import migrationRoutes from "./routes/migrations"; |
| 9a8b8de | 83 | import migrateRoutes from "./routes/migrate"; |
| 14c3cc8 | 84 | import specsRoutes from "./routes/specs"; |
| 23d0abf | 85 | import refactorRoutes from "./routes/refactors"; |
| b665cac | 86 | import codebaseMigratorRoutes from "./routes/codebase-migrator"; |
| 79136bb | 87 | import webRoutes from "./routes/web"; |
| 0316dbb | 88 | import hookRoutes from "./routes/hooks"; |
| 89 | import eventsRoutes from "./routes/events"; | |
| 90 | import passkeyRoutes from "./routes/passkeys"; | |
| 91 | import oauthRoutes from "./routes/oauth"; | |
| 92 | import developerAppsRoutes from "./routes/developer-apps"; | |
| 93 | import themeRoutes from "./routes/theme"; | |
| 94 | import auditRoutes from "./routes/audit"; | |
| 95 | import reactionRoutes from "./routes/reactions"; | |
| 96 | import savedReplyRoutes from "./routes/saved-replies"; | |
| 97 | import deploymentRoutes from "./routes/deployments"; | |
| 98 | import orgRoutes from "./routes/orgs"; | |
| 99 | import notificationRoutes from "./routes/notifications"; | |
| 100 | import onboardingRoutes from "./routes/onboarding"; | |
| 101 | import adminRoutes from "./routes/admin"; | |
| 7293c67 | 102 | import adminDeletionsRoutes from "./routes/admin-deletions"; |
| 103 | import adminStripeRoutes from "./routes/admin-stripe"; | |
| f764c07 | 104 | import adminDeploysRoutes from "./routes/admin-deploys"; |
| 105 | import adminDeploysPageRoutes from "./routes/admin-deploys-page"; | |
| 783dd46 | 106 | import adminServerTargetsRoutes from "./routes/admin-server-targets"; |
| 9aaa128 | 107 | import deployTargetsRoutes from "./routes/deploy-targets"; |
| 90c7531 | 108 | import claudeWebRoutes from "./routes/claude-web"; |
| 9dd96b9 | 109 | import adminOpsRoutes from "./routes/admin-ops"; |
| f2c00b4 | 110 | import adminSelfHostRoutes from "./routes/admin-self-host"; |
| 826eccf | 111 | import adminDiagnoseRoutes from "./routes/admin-diagnose"; |
| 509c376 | 112 | import adminIntegrationsRoutes from "./routes/admin-integrations"; |
| bc519ae | 113 | import adminEnvHealthRoutes from "./routes/admin-env-health"; |
| 79ed944 | 114 | import adminAdvancementRoutes from "./routes/admin-advancement"; |
| ba9e143 | 115 | import adminSecurityRoutes from "./routes/admin-security"; |
| 116 | import settingsSessionsRoutes from "./routes/settings-sessions"; | |
| 0316dbb | 117 | import advisoriesRoutes from "./routes/advisories"; |
| 118 | import aiChangelogRoutes from "./routes/ai-changelog"; | |
| 0a69faa | 119 | import explainRoutes from "./routes/explain"; |
| 0316dbb | 120 | import aiExplainRoutes from "./routes/ai-explain"; |
| 121 | import aiTestsRoutes from "./routes/ai-tests"; | |
| 122 | import askRoutes from "./routes/ask"; | |
| 38d31d3 | 123 | import repoChatRoutes from "./routes/repo-chat"; |
| ee7e577 | 124 | import personalChatRoutes from "./routes/personal-chat"; |
| 0316dbb | 125 | import billingRoutes from "./routes/billing"; |
| 8809b87 | 126 | import billingUsageRoutes from "./routes/billing-usage"; |
| 6778ad2 | 127 | import stripeWebhookRoutes from "./routes/stripe-webhook"; |
| 0316dbb | 128 | import codeScanningRoutes from "./routes/code-scanning"; |
| da3fc18 | 129 | import securityRoutes from "./routes/security"; |
| 0316dbb | 130 | import commitStatusesRoutes from "./routes/commit-statuses"; |
| 131 | import copilotRoutes from "./routes/copilot"; | |
| f5d020f | 132 | import { pairProgrammerRoutes } from "./routes/pair-programmer"; |
| 0316dbb | 133 | import depUpdaterRoutes from "./routes/dep-updater"; |
| 134 | import depsRoutes from "./routes/deps"; | |
| 135 | import discussionsRoutes from "./routes/discussions"; | |
| 136 | import environmentsRoutes from "./routes/environments"; | |
| 4bbacbe | 137 | import previewsRoutes from "./routes/previews"; |
| 79ed944 | 138 | import docsTrackingRoutes from "./routes/docs-tracking"; |
| 0316dbb | 139 | import followsRoutes from "./routes/follows"; |
| 140 | import gatesRoutes from "./routes/gates"; | |
| 141 | import gistsRoutes from "./routes/gists"; | |
| 142 | import graphqlRoutes from "./routes/graphql"; | |
| 2c2163e | 143 | import mcpRoutes from "./routes/mcp"; |
| 0316dbb | 144 | import marketplaceRoutes from "./routes/marketplace"; |
| 5ca514a | 145 | import marketplaceAgentsRoutes from "./routes/marketplace-agents"; |
| 0316dbb | 146 | import mergeQueueRoutes from "./routes/merge-queue"; |
| 147 | import mirrorsRoutes from "./routes/mirrors"; | |
| 148 | import orgInsightsRoutes from "./routes/org-insights"; | |
| 149 | import packagesRoutes from "./routes/packages"; | |
| 150 | import packagesApiRoutes from "./routes/packages-api"; | |
| 845fd8a | 151 | import ociRegistryRoutes from "./routes/oci-registry"; |
| 0316dbb | 152 | import pagesRoutes from "./routes/pages"; |
| 153 | import projectsRoutes from "./routes/projects"; | |
| 154 | import protectedTagsRoutes from "./routes/protected-tags"; | |
| 155 | import pwaRoutes from "./routes/pwa"; | |
| 46d6165 | 156 | import installRoutes from "./routes/install"; |
| cd4f63b | 157 | import dxtRoutes from "./routes/dxt"; |
| 662ce86 | 158 | import connectClaudeRoutes from "./routes/connect-claude"; |
| ebbb527 | 159 | import claudeDeployRoutes from "./routes/claude-deploy"; |
| f5b9ef5 | 160 | import claudeIntegration from "./routes/claude-integration"; |
| 161 | import connectRoutes from "./routes/connect"; | |
| 05ab9b1 | 162 | import pushWatchRoutes from "./routes/push-watch"; |
| 163 | import orgSecretsRoutes from "./routes/org-secrets"; | |
| 0316dbb | 164 | import releasesRoutes from "./routes/releases"; |
| 165 | import requiredChecksRoutes from "./routes/required-checks"; | |
| 166 | import rulesetsRoutes from "./routes/rulesets"; | |
| 167 | import searchRoutes from "./routes/search"; | |
| 168 | import semanticSearchRoutes from "./routes/semantic-search"; | |
| 77cf834 | 169 | import nlSearchRoutes from "./routes/nl-search"; |
| 0316dbb | 170 | import signingKeysRoutes from "./routes/signing-keys"; |
| 171 | import sponsorsRoutes from "./routes/sponsors"; | |
| 172 | import ssoRoutes from "./routes/sso"; | |
| 3a845e4 | 173 | import samlSsoRoutes from "./routes/saml-sso"; |
| 174 | import scimRoutes from "./routes/scim"; | |
| 175 | import orgSsoSettingsRoutes from "./routes/org-sso-settings"; | |
| 46d6165 | 176 | import githubOauthRoutes from "./routes/github-oauth"; |
| 582cdac | 177 | import googleOauthRoutes from "./routes/google-oauth"; |
| 0316dbb | 178 | import symbolsRoutes from "./routes/symbols"; |
| 179 | import templatesRoutes from "./routes/templates"; | |
| 180 | import trafficRoutes from "./routes/traffic"; | |
| 181 | import wikisRoutes from "./routes/wikis"; | |
| 182 | import workflowsRoutes from "./routes/workflows"; | |
| 5ff9cc2 | 183 | import workflowArtifactsRoutes from "./routes/workflow-artifacts"; |
| 184 | import workflowSecretsRoutes from "./routes/workflow-secrets"; | |
| 46d6165 | 185 | import sleepModeRoutes from "./routes/sleep-mode"; |
| 56801e1 | 186 | import standupRoutes from "./routes/standups"; |
| 52ad8b1 | 187 | import vsGithubRoutes from "./routes/vs-github"; |
| 45f3b73 | 188 | import voiceRoutes from "./routes/voice-to-pr"; |
| 3122762 | 189 | import blogRoutes from "./routes/blog"; |
| cd4f63b | 190 | import playgroundRoutes from "./routes/playground"; |
| a2b3e99 | 191 | import crossRepoSearchRoutes from "./routes/cross-repo-search"; |
| 192 | import pushNotifRoutes from "./routes/push-notifications"; | |
| 9fbe6cd | 193 | import velocityRoutes from "./routes/velocity"; |
| 194 | import { staleBranchRoutes } from "./routes/stale-branches"; | |
| 22f43f3 | 195 | import pulseRoutes from "./routes/pulse"; |
| 74d8c4d | 196 | import healthScoreRoutes from "./routes/health-score"; |
| 77cf834 | 197 | import repoHealthRoutes from "./routes/repo-health"; |
| 74d8c4d | 198 | import hotFilesRoutes from "./routes/hot-files"; |
| bcc4020 | 199 | import debtMapRoutes from "./routes/debt-map"; |
| 1d6db4d | 200 | import busFactorRoutes from "./routes/bus-factor"; |
| f5d020f | 201 | import crossRepoImpactRoutes from "./routes/cross-repo-impact"; |
| adf5e18 | 202 | import developerProgramRoutes from "./routes/developer-program"; |
| 891efbe | 203 | import shareRoutes from "./routes/share"; |
| 70e3293 | 204 | import incidentHookRoutes from "./routes/incident-hooks"; |
| 77cf834 | 205 | import workspaceRoutes from "./routes/ai-workspace"; |
| 59b6fb2 | 206 | import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit"; |
| 207 | import { csrfToken, csrfProtect } from "./middleware/csrf"; | |
| f5b9ef5 | 208 | import { noCache } from "./middleware/no-cache"; |
| 79136bb | 209 | |
| 2316901 | 210 | import type { AuthEnv } from "./middleware/auth"; |
| bf19c50 | 211 | import { softAuth } from "./middleware/auth"; |
| 2316901 | 212 | |
| 213 | const app = new Hono<AuthEnv>(); | |
| 79136bb | 214 | |
| 3ef4c9d | 215 | // Request context (request ID, start time) runs before everything else |
| 216 | app.use("*", requestContext); | |
| 05b973e | 217 | // Middleware — compression first (wraps all responses) |
| 218 | app.use("*", compress()); | |
| f1ffd50 | 219 | |
| 220 | // ETag middleware — returns 304 Not Modified on unchanged responses. | |
| 221 | // Saves ~95% bandwidth on repeat visits. Skipped on git protocol + | |
| 222 | // SSE + the API surface where it would interfere with streaming. | |
| 223 | app.use("*", async (c, next) => { | |
| 224 | const p = c.req.path; | |
| 225 | if ( | |
| 226 | p.includes(".git/") || | |
| 227 | p.startsWith("/live-events") || | |
| 228 | p.startsWith("/api/events/deploy") || | |
| 3c03977 | 229 | p.startsWith("/admin/status") || |
| 230 | // PR live co-editing SSE stream — never etag streaming responses. | |
| 231 | /^\/api\/v2\/pulls\/[^/]+\/live(\/|$)/.test(p) | |
| f1ffd50 | 232 | ) { |
| 233 | return next(); | |
| 234 | } | |
| 235 | return etag()(c, next); | |
| 236 | }); | |
| 237 | ||
| 238 | // Cache-Control middleware — sets sensible defaults on public, anonymous | |
| 239 | // requests. Crontech (when wired as our edge layer) and downstream | |
| 240 | // browsers will honor these. Auth'd users get private,no-store | |
| 241 | // automatically — we never cache responses tied to a session. | |
| 242 | app.use("*", async (c, next) => { | |
| 243 | await next(); | |
| 244 | // Don't overwrite explicit headers set by route handlers — BUT the | |
| 245 | // ETag middleware unconditionally sets "private, no-cache, must- | |
| 246 | // revalidate" so we have to treat that specific value as "no | |
| 247 | // policy chosen yet" and apply ours. Any route that explicitly set | |
| 248 | // a different cache-control wins. | |
| 249 | const existing = c.res.headers.get("cache-control"); | |
| 250 | const etagDefault = | |
| 251 | existing === "private, no-cache, must-revalidate" || | |
| 252 | existing === "no-cache"; | |
| 253 | if (existing && !etagDefault) return; | |
| 254 | // Anything past auth: private + no-store (avoid leaking session | |
| 255 | // content into shared caches). softAuth runs before this on the | |
| 256 | // request, but the response side is what we're stamping. | |
| 257 | const hasSession = c.req.header("cookie")?.includes("session=") ?? false; | |
| 258 | const p = c.req.path; | |
| 259 | // Always private for known-authed paths regardless of cookie. | |
| 260 | if ( | |
| 261 | p.startsWith("/admin") || | |
| 262 | p.startsWith("/settings") || | |
| 263 | p.startsWith("/dashboard") || | |
| 264 | p.startsWith("/notifications") || | |
| 265 | p.startsWith("/connect/") || | |
| 266 | hasSession | |
| 267 | ) { | |
| 268 | c.res.headers.set("cache-control", "private, no-store"); | |
| 269 | return; | |
| 270 | } | |
| 271 | // Public marketing surfaces — short edge cache, longer browser cache, | |
| 272 | // stale-while-revalidate so the user never waits on a stale fetch. | |
| 273 | const isMarketing = | |
| 274 | p === "/" || | |
| 275 | p === "/features" || | |
| 276 | p === "/pricing" || | |
| 277 | p === "/about" || | |
| 278 | p === "/vs-github" || | |
| 279 | p === "/explore" || | |
| 280 | p === "/help" || | |
| 281 | p === "/changelog" || | |
| 9f29b65 | 282 | p === "/enterprise" || |
| f1ffd50 | 283 | p.startsWith("/legal/") || |
| 284 | p === "/terms" || | |
| 285 | p === "/privacy" || | |
| 286 | p === "/acceptable-use" || | |
| 287 | p.startsWith("/docs/"); | |
| 288 | if (isMarketing) { | |
| 289 | c.res.headers.set( | |
| 290 | "cache-control", | |
| 291 | "public, max-age=60, s-maxage=300, stale-while-revalidate=86400" | |
| 292 | ); | |
| 293 | return; | |
| 294 | } | |
| 295 | // Public repo browse pages — cache aggressively. Edge invalidates | |
| 296 | // on push via the post-receive hook (future Crontech surge purge). | |
| 297 | if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") { | |
| 298 | c.res.headers.set( | |
| 299 | "cache-control", | |
| 300 | "public, max-age=30, s-maxage=120, stale-while-revalidate=600" | |
| 301 | ); | |
| 302 | return; | |
| 303 | } | |
| 304 | // Default: don't cache anything we haven't explicitly opted in. | |
| 305 | c.res.headers.set("cache-control", "private, no-store"); | |
| 306 | }); | |
| 05b973e | 307 | // Logger only on non-git routes to avoid overhead on clone/push |
| 308 | app.use("*", async (c, next) => { | |
| 309 | if (c.req.path.includes(".git/")) return next(); | |
| 310 | return logger()(c, next); | |
| 311 | }); | |
| 79136bb | 312 | app.use("/api/*", cors()); |
| bf19c50 | 313 | // Global softAuth — populates c.get("user") for every downstream middleware |
| 314 | // + route. This was previously per-route, which meant rate-limit middleware | |
| 315 | // (and anything else inspecting auth state) always saw a null user. Keep | |
| 316 | // individual routes free to add requireAuth on top for hard gating; this | |
| 317 | // just establishes the user object cheaply. | |
| 318 | app.use("*", softAuth); | |
| 290ea77 | 319 | |
| 36cc17a | 320 | // Force-revalidate HTML on every request — kills browser cache holding stale |
| 290ea77 | 321 | // pre-redesign markup. JSON / static assets keep their own cache rules; only |
| 322 | // text/html responses get the no-cache stamp. Without this, every push to | |
| 323 | // main left users staring at cached 80s-looking pages from before the design | |
| 324 | // landed. | |
| 36cc17a | 325 | // |
| 326 | // We deliberately use `private, no-cache, must-revalidate` rather than | |
| 327 | // `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache), | |
| 328 | // which makes every Back/Forward press a cold server round-trip — that | |
| 329 | // contributed to the "every nav feels like a fresh login" UX complaint. | |
| 330 | // `no-cache` still revalidates on direct fetch but lets bfcache hold the | |
| 331 | // page in memory between navigations. | |
| 290ea77 | 332 | app.use("*", async (c, next) => { |
| 333 | await next(); | |
| 334 | const ct = c.res.headers.get("content-type") || ""; | |
| 335 | if (ct.startsWith("text/html")) { | |
| 36cc17a | 336 | c.header("cache-control", "private, no-cache, must-revalidate"); |
| 290ea77 | 337 | } |
| 338 | }); | |
| 826eccf | 339 | // Rate-limit API + auth endpoints. |
| 340 | // | |
| a41e675 | 341 | // `/api/*`: 1000/min per IP — generous so an admin clicking around the |
| 342 | // operator console (or a CDN/proxy concentrating multiple users behind one | |
| 343 | // IP) doesn't hit the wall. Bot-resistant headroom comes from the auth | |
| 344 | // rate limits below, not this one. | |
| 345 | // | |
| 346 | // `authedMultiplier` is set but only fires when an upstream middleware has | |
| 347 | // already populated c.get("user") — most app.use() chains apply softAuth | |
| 348 | // per-route, so the multiplier is best-effort. Keep the anonymous base | |
| 349 | // high enough that humans never feel it. | |
| 350 | // | |
| 351 | // Skip-paths: dashboard plumbing endpoints that the layout polls on a | |
| 352 | // fixed cadence and that we don't want consuming any bucket: | |
| 353 | // /api/version — layout polls every 15s | |
| 826eccf | 354 | // /api/notifications/count — nav bell unread-count fetcher |
| 355 | // /pwa/vapid-public-key — fetched once per push-notification opt-in | |
| 356 | app.use( | |
| 357 | "/api/*", | |
| a41e675 | 358 | rateLimit(1000, 60_000, "api", { |
| 826eccf | 359 | authedMultiplier: 4, |
| 360 | skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"], | |
| 361 | }) | |
| 362 | ); | |
| 0316dbb | 363 | app.use("/login", rateLimit(20, 60_000, "login")); |
| 364 | app.use("/register", rateLimit(10, 60_000, "register")); | |
| c63b860 | 365 | // BLOCK P1 — throttle forgot-password to deter enumeration + mail spam. |
| 366 | app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password")); | |
| cd4f63b | 367 | // BLOCK Q2 — throttle magic-link sign-in for the same reason. |
| 368 | app.use("/login/magic", rateLimit(5, 60_000, "magic-link")); | |
| 79136bb | 369 | |
| 59b6fb2 | 370 | // CSRF protection — set token on all requests, validate on mutations |
| 371 | app.use("*", csrfToken); | |
| 372 | app.use("*", csrfProtect); | |
| 373 | ||
| 45e31d0 | 374 | // Rate limit auth routes |
| 375 | app.use("/login", authRateLimit); | |
| 376 | app.use("/register", authRateLimit); | |
| 377 | ||
| 59b6fb2 | 378 | // Rate limit git operations |
| 379 | app.use("/:owner/:repo.git/*", gitRateLimit); | |
| 380 | ||
| 381 | // Rate limit search | |
| 382 | app.use("/:owner/:repo/search", searchRateLimit); | |
| 383 | app.use("/explore", searchRateLimit); | |
| 79136bb | 384 | |
| f5b9ef5 | 385 | // No-cache for HTML — ensures browsers and proxies never serve stale pages. |
| 386 | // The middleware only stamps text/html responses so static assets keep | |
| 387 | // their own cache policies unchanged. | |
| 388 | app.use("*", noCache); | |
| 389 | ||
| 79136bb | 390 | // Git Smart HTTP protocol routes (must be before web routes) |
| 391 | app.route("/", gitRoutes); | |
| 392 | ||
| 45e31d0 | 393 | // REST API v1 (legacy) |
| 79136bb | 394 | app.route("/", apiRoutes); |
| 395 | ||
| 52ad8b1 | 396 | // Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE |
| 397 | // apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base | |
| 398 | // router's catch-shape, and BEFORE adminRoutes so the live /demo page | |
| 399 | // wins over the legacy /demo redirect in src/routes/admin.tsx. | |
| 400 | app.route("/", demoRoutes); | |
| 401 | ||
| 0316dbb | 402 | // REST API v2 (basePath /api/v2) |
| 403 | app.route("/", apiV2Routes); | |
| 404 | ||
| e75eddc | 405 | // Agent multiplayer v1 — /api/v2/agents/* (sessions, leases, usage). |
| 406 | // Mounted alongside apiV2Routes (its own basePath, no path conflict). | |
| 407 | app.route("/", agentsRoutes); | |
| 408 | ||
| ef3fd93 | 409 | // Multi-agent pipeline UI — /:owner/:repo/agents (list, new, live view). |
| 410 | // Must be before webRoutes (the catch-all) so the /agents sub-paths are | |
| 411 | // resolved before the generic tree/blob route takes over. | |
| 412 | app.route("/", agentPipelinesRoutes); | |
| 413 | ||
| ad6d4ad | 414 | // Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs) |
| 415 | app.route("/", hookRoutes); | |
| 21f8dbd | 416 | app.route("/api/events", eventsRoutes); |
| ad6d4ad | 417 | |
| 45e31d0 | 418 | // API documentation |
| 419 | app.route("/", apiDocsRoutes); | |
| 4a80519 | 420 | app.route("/", buildAgentSpecRoutes); |
| a6ff0f2 | 421 | // PR command center — global PR dashboard with AI/GateTest/auto-merge signal |
| 422 | app.route("/", pullsDashboardRoutes); | |
| e9aa4d8 | 423 | // Issue command center — global issue dashboard with AI-triage + autopilot signal |
| 424 | app.route("/", issuesDashboardRoutes); | |
| 425 | // Personal activity timeline — every event across the user's repos, with | |
| 426 | // AI-driven events surfaced separately (the Gluecron differentiator). | |
| 427 | app.route("/", activityRoutes); | |
| 428 | // Unified inbox — mentions + review requests + CI failures + AI events in one timeline | |
| 429 | app.route("/", inboxRoutes); | |
| 56801e1 | 430 | // AI standup feed — daily / weekly Claude-generated team brief |
| 431 | app.route("/", standupRoutes); | |
| cc34156 | 432 | // Smart morning digest — AI-curated daily developer queue (/digest) |
| 433 | app.route("/", digestRoutes); | |
| 79136bb | 434 | |
| 435 | // Auth routes (register, login, logout) | |
| 436 | app.route("/", authRoutes); | |
| 437 | ||
| c63b860 | 438 | // BLOCK P1 — Password reset (forgot-password + reset-password) |
| 439 | app.route("/", passwordResetRoutes); | |
| 440 | ||
| 441 | // BLOCK P2 — Email verification (verify-email + resend) | |
| 442 | app.route("/", emailVerificationRoutes); | |
| 443 | ||
| cd4f63b | 444 | // BLOCK Q2 — Magic-link sign-in (/login/magic + callback) |
| 445 | app.route("/", magicLinkRoutes); | |
| 446 | ||
| 79136bb | 447 | // Settings routes (profile, SSH keys) |
| 448 | app.route("/", settingsRoutes); | |
| 449 | ||
| ba9e143 | 450 | // Session management (SOC 2 CC6.1 — /settings/sessions) |
| 451 | app.route("/", settingsSessionsRoutes); | |
| 452 | ||
| 7298a17 | 453 | // 2FA / TOTP settings (Block B4) |
| 454 | app.route("/", settings2faRoutes); | |
| 455 | ||
| e75eddc | 456 | // Agent multiplayer — /settings/agents management UI |
| 457 | app.route("/", settingsAgentsRoutes); | |
| 458 | ||
| 1d4ff60 | 459 | // Chat integrations — Slack / Discord / Teams (/settings/integrations |
| 460 | // + /api/v2/integrations/{slack,discord}/*). See src/lib/chat-bot.ts. | |
| 461 | app.route("/", settingsIntegrationsRoutes); | |
| 462 | app.route("/", integrationsChatRoutes); | |
| 463 | ||
| 2df1f8c | 464 | // WebAuthn / passkey routes (Block B5) |
| 465 | app.route("/", passkeyRoutes); | |
| 466 | ||
| 058d752 | 467 | // OAuth 2.0 provider (Block B6) |
| 468 | app.route("/", oauthRoutes); | |
| 469 | app.route("/", developerAppsRoutes); | |
| 470 | ||
| 6fc53bd | 471 | // Theme toggle (dark/light cookie) |
| 472 | app.route("/", themeRoutes); | |
| 473 | ||
| 474 | // Audit log UI | |
| 475 | app.route("/", auditRoutes); | |
| 476 | ||
| 477 | // Reactions API (issues, PRs, comments) | |
| 478 | app.route("/", reactionRoutes); | |
| 479 | ||
| 24cf2ca | 480 | // Saved replies (per-user canned comment templates) |
| 481 | app.route("/", savedReplyRoutes); | |
| 482 | ||
| 483 | // Environments + deployment history UI | |
| 484 | app.route("/", deploymentRoutes); | |
| 485 | ||
| 6563f0a | 486 | // Organizations + teams (Block B1) |
| 487 | app.route("/", orgRoutes); | |
| 488 | ||
| c81ab7a | 489 | // API tokens |
| 490 | app.route("/", tokenRoutes); | |
| 491 | ||
| 59b6fb2 | 492 | // Notifications |
| 3ef4c9d | 493 | app.route("/", notificationRoutes); |
| 494 | ||
| 79136bb | 495 | // Repo settings (description, visibility, delete) |
| 496 | app.route("/", repoSettings); | |
| 479dcd9 | 497 | // Per-repo automation settings (off / suggest / auto) — migration 0106 |
| 498 | app.route("/", automationSettingsRoutes); | |
| 79136bb | 499 | |
| 23d1a81 | 500 | // Repo collaborators (add/list/remove) |
| 501 | app.route("/", collaboratorRoutes); | |
| 502 | ||
| 04f6b7f | 503 | // Team-based repo collaborators (invite a whole team) |
| 504 | app.route("/", teamCollaboratorRoutes); | |
| 505 | ||
| 506 | // Collaborator invite accept flow (token-based) | |
| 507 | app.route("/", invitesRoutes); | |
| 508 | ||
| 509 | // Real-time SSE endpoint (topic-based live updates) | |
| 510 | app.route("/", liveEventsRoutes); | |
| 511 | ||
| 3c03977 | 512 | // PR live co-editing — presence + cursors + content sync via SSE. |
| 513 | app.route("/", prLiveRoutes); | |
| 514 | ||
| c81ab7a | 515 | // Webhooks management |
| 516 | app.route("/", webhookRoutes); | |
| 517 | ||
| 79136bb | 518 | // Compare view (branch diffs) |
| 519 | app.route("/", compareRoutes); | |
| 520 | ||
| 521 | // Issue tracker | |
| 522 | app.route("/", issueRoutes); | |
| 523 | ||
| 85c4e13 | 524 | // Milestones — group issues + PRs toward a shared goal with due dates + progress tracking. |
| 525 | // Mounted after issueRoutes so /:owner/:repo/issues/* paths win before the milestone patterns. | |
| 526 | app.route("/", milestonesRoutes); | |
| 527 | ||
| f928118 | 528 | // Ship Agent — autonomous AI feature implementation |
| 529 | app.route("/", shipAgentRoutes); | |
| 530 | ||
| 77cf834 | 531 | // AI Copilot Workspace — issue-to-PR autonomous agent |
| 532 | app.route("/", workspaceRoutes); | |
| 533 | ||
| cb5a796 | 534 | // Comment moderation queue — owner-only `/:owner/:repo/comments/pending` |
| 535 | // + per-row approve/reject/spam actions. Mounted before `pullRoutes` so | |
| 536 | // the `/:owner/:repo/comments/*` paths resolve before the broader PR | |
| 537 | // patterns kick in. | |
| 538 | app.route("/", commentModerationRoutes); | |
| 539 | ||
| 0074234 | 540 | // Pull requests |
| 541 | app.route("/", pullRoutes); | |
| 09d5f39 | 542 | |
| 543 | // /stage PR preview — serve built static files from .stage-previews/{jobId}/ | |
| 544 | // Registered immediately after pullRoutes so the path `/preview/:id/*` is | |
| 545 | // specific enough to never clash with repo browse routes (`/:owner/:repo/*`). | |
| 546 | app.get("/preview/:stageJobId/*", async (c) => { | |
| 547 | const { stageJobId } = c.req.param(); | |
| 548 | // Validate job ID format (UUID) | |
| 549 | if (!/^[0-9a-f-]{32,}$/i.test(stageJobId)) { | |
| 550 | return c.text("Not found", 404); | |
| 551 | } | |
| 552 | const { getPreviewDir, isPreviewExpired } = await import("./lib/pr-stage"); | |
| 553 | if (isPreviewExpired(stageJobId)) { | |
| 554 | return c.html( | |
| 555 | "<html><body style='font-family:sans-serif;padding:40px;color:#888'>" + | |
| 556 | "<h2>Preview expired</h2><p>This stage preview has expired (48h TTL). " + | |
| 557 | "Comment <code>/stage</code> on the PR to redeploy.</p></body></html>", | |
| 558 | 410 | |
| 559 | ); | |
| 560 | } | |
| 561 | const { join } = await import("path"); | |
| 562 | const previewDir = getPreviewDir(stageJobId); | |
| 563 | // Extract the wildcard path after /preview/:id/ | |
| 564 | const rawPath = c.req.path.replace(/^\/preview\/[^/]+/, "") || "/"; | |
| 565 | const filePath = rawPath === "/" || rawPath === "" ? "/index.html" : rawPath; | |
| 566 | const fullPath = join(previewDir, filePath); | |
| 567 | const file = Bun.file(fullPath); | |
| 568 | if (!(await file.exists())) { | |
| 569 | // Try index.html fallback (SPA behaviour) | |
| 570 | const indexFile = Bun.file(join(previewDir, "index.html")); | |
| 571 | if (await indexFile.exists()) { | |
| 572 | const html = await indexFile.text(); | |
| 573 | return c.html(html); | |
| 574 | } | |
| 575 | return c.text("Not found", 404); | |
| 576 | } | |
| 577 | const content = await file.arrayBuffer(); | |
| 578 | const ext = fullPath.split(".").pop()?.toLowerCase() ?? ""; | |
| 579 | const contentTypeMap: Record<string, string> = { | |
| 580 | html: "text/html; charset=utf-8", | |
| 581 | htm: "text/html; charset=utf-8", | |
| 582 | css: "text/css; charset=utf-8", | |
| 583 | js: "application/javascript; charset=utf-8", | |
| 584 | mjs: "application/javascript; charset=utf-8", | |
| 585 | json: "application/json; charset=utf-8", | |
| 586 | png: "image/png", | |
| 587 | jpg: "image/jpeg", | |
| 588 | jpeg: "image/jpeg", | |
| 589 | gif: "image/gif", | |
| 590 | svg: "image/svg+xml", | |
| 591 | ico: "image/x-icon", | |
| 592 | webp: "image/webp", | |
| 593 | woff: "font/woff", | |
| 594 | woff2: "font/woff2", | |
| 595 | ttf: "font/ttf", | |
| 596 | txt: "text/plain; charset=utf-8", | |
| 597 | xml: "application/xml", | |
| 598 | webmanifest: "application/manifest+json", | |
| 599 | }; | |
| 600 | const ct = contentTypeMap[ext] ?? "application/octet-stream"; | |
| 601 | return c.body(content, 200, { | |
| 602 | "content-type": ct, | |
| 603 | "cache-control": "public, max-age=300", | |
| 604 | "x-stage-job-id": stageJobId, | |
| 605 | }); | |
| 606 | }); | |
| 607 | ||
| 79ed944 | 608 | // PR sandboxes — runnable per-PR environments. Migration 0067. |
| 609 | app.route("/", prSandboxRoutes); | |
| 0074234 | 610 | |
| 9b3a183 | 611 | // Cloud dev environments — hosted VS Code in the browser. Migration 0072. |
| 612 | app.route("/", devEnvRoutes); | |
| 613 | ||
| c81ab7a | 614 | // Fork |
| 615 | app.route("/", forkRoutes); | |
| 616 | ||
| 0074234 | 617 | // Web file editor |
| 618 | app.route("/", editorRoutes); | |
| 619 | ||
| 6f2809f | 620 | // AI editor API routes (inline suggestions, explain, fix) |
| 621 | app.route("/", aiEditorRoutes); | |
| 622 | ||
| 43de941 | 623 | // Contributors |
| 624 | app.route("/", contributorRoutes); | |
| 625 | ||
| 699e5c7 | 626 | // Health liveness + metrics endpoints |
| 2c34075 | 627 | app.route("/", healthRoutes); |
| 628 | ||
| f295f78 | 629 | // Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md) |
| 630 | app.route("/api/platform-status", platformStatus); | |
| 631 | ||
| 52ad8b1 | 632 | // Block L4 — Public stats counters (powers landing-page social proof) |
| 633 | app.route("/", publicStatsRoutes); | |
| 634 | ||
| 635 | // Block L3 — Live /demo page + /api/v2/demo/* endpoints | |
| 636 | app.route("/", demoRoutes); | |
| 637 | ||
| 2316be6 | 638 | // Public /status — human-readable platform health page |
| 639 | app.route("/", statusRoutes); | |
| 640 | ||
| b1be050 | 641 | // BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status). |
| 642 | // Mounted near the public status route so the two surfaces are visible | |
| 643 | // side-by-side; routes are gated by isSiteAdmin internally. | |
| 644 | app.route("/", adminStatusRoutes); | |
| 645 | ||
| 80bed05 | 646 | // /help — quickstart + API cheatsheet |
| 647 | app.route("/", helpRoutes); | |
| 648 | ||
| e0e4219 | 649 | // /docs — expanded documentation site (getting started, workflow YAML, MCP, API, agents) |
| 650 | app.route("/", docsRoutes); | |
| 651 | ||
| 5f2e749 | 652 | // L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing |
| 653 | // so the new editorial pricing layout wins the route; the legacy marketing | |
| 654 | // pricing remains as a safety net but is shadowed at the router. | |
| 655 | app.route("/", pricingRoutes); | |
| 656 | ||
| e1fc7db | 657 | // /changelog — manually curated platform release history |
| 658 | app.route("/", changelogRoutes); | |
| 659 | ||
| 9f29b65 | 660 | // Enterprise sales page + contact form lead capture. |
| 661 | app.route("/", enterpriseRoutes); | |
| 662 | ||
| b0148e9 | 663 | // /pricing, /features, /about — marketing surface |
| 664 | app.route("/", marketingRoutes); | |
| 665 | ||
| adf5e18 | 666 | // /developer-program — partner + marketplace revenue-share page |
| 667 | app.route("/", developerProgramRoutes); | |
| 668 | ||
| 5618f9a | 669 | // SEO: robots.txt + sitemap.xml |
| 670 | app.route("/", seoRoutes); | |
| 671 | ||
| 05cdb85 | 672 | // /api/version — live build SHA + uptime; client poller uses this to |
| 673 | // surface 'New version available — reload' banners on deploy. | |
| 674 | app.route("/", versionRoutes); | |
| 675 | ||
| 699e5c7 | 676 | // Health dashboard (per-repo health page) |
| 677 | app.route("/", healthDashboardRoutes); | |
| 678 | ||
| 9dd96b9 | 679 | // Block R1 — site-admin operations console. MUST be mounted BEFORE |
| 680 | // insightRoutes because its POST `/:owner/:repo/rollback` catch-all would | |
| 681 | // otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops). | |
| 682 | app.route("/", adminOpsRoutes); | |
| f2c00b4 | 683 | // BLOCK W — Self-host status + bootstrap dashboard. |
| 684 | app.route("/", adminSelfHostRoutes); | |
| 826eccf | 685 | // BLOCK X — AI health-scan diagnose page (/admin/diagnose). |
| 686 | app.route("/", adminDiagnoseRoutes); | |
| 9dd96b9 | 687 | |
| 16b325c | 688 | // Insights (time-travel, dependencies, rollback) |
| 689 | app.route("/", insightRoutes); | |
| 690 | ||
| 8286942 | 691 | // Engineering Intelligence Dashboard — /insights + /:owner/:repo/insights/engineering |
| 692 | app.route("/", engineeringInsightsRoutes); | |
| 693 | ||
| 8d1483c | 694 | // DORA metrics page (/:owner/:repo/insights/dora) |
| 695 | app.route("/", doraRoutes); | |
| 696 | ||
| f1ab587 | 697 | // Command center dashboard |
| 698 | app.route("/", dashboardRoutes); | |
| 699 | ||
| 36b4cbd | 700 | // Legal pages (terms, privacy, AUP) |
| 701 | app.route("/", legalRoutes); | |
| 4b66018 | 702 | // Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}. |
| 703 | // The main `legal.tsx` serves the short canonical paths (/terms, /privacy, | |
| 704 | // /acceptable-use); these are the formal versions that the legal pages | |
| 705 | // internally link to each other. | |
| 706 | app.route("/", legalTermsRoutes); | |
| 707 | app.route("/", legalPrivacyRoutes); | |
| 708 | app.route("/", legalAcceptableUseRoutes); | |
| 709 | app.route("/", legalDmcaRoutes); | |
| 36b4cbd | 710 | |
| bdbd0de | 711 | // GitHub import / migration |
| 712 | app.route("/", importRoutes); | |
| 14c3cc8 | 713 | app.route("/", importBulkRoutes); |
| f390cfa | 714 | app.route("/", importSecretsRoutes); |
| bb2dea9 | 715 | // GitHub Actions → Gluecron gates.yml importer (stateless converter) |
| 716 | app.route("/", actionsImporterRoutes); | |
| 14c3cc8 | 717 | app.route("/", migrationRoutes); |
| 9a8b8de | 718 | // GitHub Org Migration Wizard — live progress bulk importer |
| 719 | app.route("/", migrateRoutes); | |
| 14c3cc8 | 720 | |
| 721 | // Spec-to-PR (experimental AI-generated draft PRs) | |
| 722 | app.route("/", specsRoutes); | |
| 23d0abf | 723 | app.route("/", refactorRoutes); |
| b665cac | 724 | app.route("/", codebaseMigratorRoutes); |
| bdbd0de | 725 | |
| c81ab7a | 726 | // Explore page |
| 727 | app.route("/", exploreRoutes); | |
| 728 | ||
| 59b6fb2 | 729 | // Onboarding |
| 730 | app.route("/", onboardingRoutes); | |
| 731 | ||
| 0316dbb | 732 | // Admin + feature routes |
| 733 | app.route("/", adminRoutes); | |
| 7293c67 | 734 | app.route("/", adminDeletionsRoutes); |
| 735 | app.route("/", adminStripeRoutes); | |
| ba9e143 | 736 | |
| 737 | // SOC 2 security dashboard + readiness checklist (/admin/security, /admin/soc2) | |
| 738 | app.route("/", adminSecurityRoutes); | |
| 509c376 | 739 | app.route("/", adminIntegrationsRoutes); |
| bc519ae | 740 | app.route("/", adminEnvHealthRoutes); |
| 79ed944 | 741 | app.route("/", adminAdvancementRoutes); |
| f764c07 | 742 | app.route("/", adminDeploysRoutes); |
| 743 | app.route("/", adminDeploysPageRoutes); | |
| 783dd46 | 744 | app.route("/", adminServerTargetsRoutes); |
| 9aaa128 | 745 | app.route("/", deployTargetsRoutes); |
| 90c7531 | 746 | app.route("/", claudeWebRoutes); |
| 9dd96b9 | 747 | // Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above. |
| 0316dbb | 748 | app.route("/", advisoriesRoutes); |
| 749 | app.route("/", aiChangelogRoutes); | |
| 0a69faa | 750 | // "Explain This Repo" — rich structured AI analysis dashboard (mounted before |
| 751 | // the simpler aiExplainRoutes so the new routes win on /:owner/:repo/explain). | |
| 752 | app.route("/", explainRoutes); | |
| 0316dbb | 753 | app.route("/", aiExplainRoutes); |
| 754 | app.route("/", aiTestsRoutes); | |
| 755 | app.route("/", askRoutes); | |
| 38d31d3 | 756 | app.route("/", repoChatRoutes); |
| ee7e577 | 757 | // Personal cross-repo chat — `/chat` (user-scoped). Mounted alongside |
| 758 | // repoChatRoutes so the two surfaces share the catch-all priority. | |
| 759 | app.route("/", personalChatRoutes); | |
| 0316dbb | 760 | app.route("/", billingRoutes); |
| 8809b87 | 761 | app.route("/", billingUsageRoutes); |
| 6778ad2 | 762 | app.route("/", stripeWebhookRoutes); |
| 0316dbb | 763 | app.route("/", codeScanningRoutes); |
| da3fc18 | 764 | // Dependency CVE scanner findings page — /:owner/:repo/security/vulnerabilities |
| 765 | app.route("/", securityRoutes); | |
| 0316dbb | 766 | app.route("/", commitStatusesRoutes); |
| 767 | app.route("/", copilotRoutes); | |
| f5d020f | 768 | app.route("/", pairProgrammerRoutes); |
| 0316dbb | 769 | app.route("/", depUpdaterRoutes); |
| 770 | app.route("/", depsRoutes); | |
| 771 | app.route("/", discussionsRoutes); | |
| 772 | app.route("/", environmentsRoutes); | |
| 4bbacbe | 773 | app.route("/", previewsRoutes); |
| 79ed944 | 774 | app.route("/", docsTrackingRoutes); |
| 0316dbb | 775 | app.route("/", followsRoutes); |
| 776 | app.route("/", gatesRoutes); | |
| 777 | app.route("/", gistsRoutes); | |
| 778 | app.route("/", graphqlRoutes); | |
| 2c2163e | 779 | app.route("/", mcpRoutes); |
| 0316dbb | 780 | app.route("/", marketplaceRoutes); |
| 5ca514a | 781 | app.route("/", marketplaceAgentsRoutes); |
| 0316dbb | 782 | app.route("/", mergeQueueRoutes); |
| 783 | app.route("/", mirrorsRoutes); | |
| 784 | app.route("/", orgInsightsRoutes); | |
| 785 | app.route("/", packagesRoutes); | |
| 786 | app.route("/", packagesApiRoutes); | |
| 845fd8a | 787 | // OCI / Docker container registry — /v2/* (OCI Distribution Spec v1.0) |
| 788 | app.route("/", ociRegistryRoutes); | |
| 0316dbb | 789 | app.route("/", pagesRoutes); |
| 790 | app.route("/", projectsRoutes); | |
| 791 | app.route("/", protectedTagsRoutes); | |
| 792 | app.route("/", pwaRoutes); | |
| 46d6165 | 793 | app.route("/", installRoutes); |
| cd4f63b | 794 | // BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension) |
| 795 | app.route("/", dxtRoutes); | |
| 662ce86 | 796 | // Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted |
| 797 | // next to the other one-click flows (install.sh + .dxt) for surface symmetry. | |
| 798 | app.route("/", connectClaudeRoutes); | |
| f5b9ef5 | 799 | // Claude Code Integration Receiver — /api/claude/connect + /api/claude/session. |
| 800 | app.route("/", claudeIntegration); | |
| 801 | // Connect guide — public onboarding page (/connect/claude-guide). | |
| 802 | app.route("/", connectRoutes); | |
| 05ab9b1 | 803 | // Push Watch — per-commit live status (gates + deploy + latency) at /:owner/:repo/push/:sha |
| 804 | app.route("/", pushWatchRoutes); | |
| 805 | // Org Secrets Manager — BLOCK M2 — /orgs/:slug/settings/secrets | |
| 806 | app.route("/", orgSecretsRoutes); | |
| a2b3e99 | 807 | // Cross-repo code search — BLOCK M3 — /search/code + /api/search/code |
| 808 | app.route("/", crossRepoSearchRoutes); | |
| 809 | // Browser push notifications — BLOCK M4 — /settings/notifications/push + /api/push/* | |
| 810 | app.route("/", pushNotifRoutes); | |
| 9fbe6cd | 811 | // Developer Velocity Dashboard — BLOCK M9 — /:owner/:repo/insights/velocity |
| 812 | app.route("/", velocityRoutes); | |
| 813 | // Stale Branch Cleanup — BLOCK M10 — /:owner/:repo/branches/stale | |
| 814 | app.route("/", staleBranchRoutes); | |
| 22f43f3 | 815 | // Repository Pulse — BLOCK M12 — /:owner/:repo/pulse |
| 816 | app.route("/", pulseRoutes); | |
| 74d8c4d | 817 | // Repository Health Score — BLOCK M14 — /:owner/:repo/insights/health |
| 818 | app.route("/", healthScoreRoutes); | |
| 77cf834 | 819 | // Repository Health Score breakdown page — /:owner/:repo/health |
| 820 | app.route("/", repoHealthRoutes); | |
| 74d8c4d | 821 | // Hot Files Heatmap — BLOCK M16 — /:owner/:repo/insights/hotfiles |
| 822 | app.route("/", hotFilesRoutes); | |
| bcc4020 | 823 | // AI Technical Debt Map — /:owner/:repo/debt-map (visual debt graph + Claude analysis) |
| 824 | app.route("/", debtMapRoutes); | |
| 1d6db4d | 825 | // Bus Factor Analysis — /:owner/:repo/insights/bus-factor |
| 826 | app.route("/", busFactorRoutes); | |
| f5d020f | 827 | // Cross-Repo Dependency Impact Detection — /:owner/:repo/pulls/:number/cross-repo-impact |
| 828 | app.route("/", crossRepoImpactRoutes); | |
| ebbb527 | 829 | // Hosted Claude tool-use loops — paste loop, get endpoint, billing meter. |
| 830 | // See src/routes/claude-deploy.tsx + src/lib/hosted-claude-loop.ts. | |
| 831 | app.route("/", claudeDeployRoutes); | |
| 0316dbb | 832 | app.route("/", releasesRoutes); |
| 833 | app.route("/", requiredChecksRoutes); | |
| 834 | app.route("/", rulesetsRoutes); | |
| 835 | app.route("/", searchRoutes); | |
| 836 | app.route("/", semanticSearchRoutes); | |
| 77cf834 | 837 | app.route("/", nlSearchRoutes); |
| 0316dbb | 838 | app.route("/", signingKeysRoutes); |
| 839 | app.route("/", sponsorsRoutes); | |
| 840 | app.route("/", ssoRoutes); | |
| 3a845e4 | 841 | // Enterprise per-org SAML 2.0 + OIDC SSO routes |
| 842 | app.route("/", samlSsoRoutes); | |
| 843 | // SCIM 2.0 user provisioning endpoints | |
| 844 | app.route("/", scimRoutes); | |
| 845 | // Per-org SSO + SCIM admin settings UI | |
| 846 | app.route("/", orgSsoSettingsRoutes); | |
| 46d6165 | 847 | app.route("/", githubOauthRoutes); |
| 582cdac | 848 | app.route("/", googleOauthRoutes); |
| 0316dbb | 849 | app.route("/", symbolsRoutes); |
| 850 | app.route("/", templatesRoutes); | |
| 851 | app.route("/", trafficRoutes); | |
| 852 | app.route("/", wikisRoutes); | |
| 853 | app.route("/", workflowsRoutes); | |
| 5ff9cc2 | 854 | app.route("/", workflowArtifactsRoutes); |
| 855 | app.route("/", workflowSecretsRoutes); | |
| 46d6165 | 856 | app.route("/", sleepModeRoutes); |
| 52ad8b1 | 857 | app.route("/", vsGithubRoutes); |
| 0316dbb | 858 | |
| 45f3b73 | 859 | // Voice-to-PR — phone-first dictation → spec or issue |
| 860 | app.route("/", voiceRoutes); | |
| 861 | ||
| 3122762 | 862 | // Blog / Devlog — public posts, no DB |
| 863 | app.route("/", blogRoutes); | |
| 864 | ||
| cd4f63b | 865 | // Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted |
| 866 | // before the web catch-all so the bare `/play` literal wins over the | |
| 867 | // `/:owner` user-profile route. | |
| 868 | app.route("/", playgroundRoutes); | |
| 869 | ||
| 891efbe | 870 | // Shareable AI hours-saved OG image card + landing page. |
| 871 | // /share/hours-saved?user=:username → 1200×630 SVG (og:image) | |
| 872 | // /share/:username → HTML page with og:image meta + Twitter share | |
| 873 | // Mounted BEFORE webRoutes so /share/* doesn't fall through to the /:owner profile route. | |
| 874 | app.route("/", shareRoutes); | |
| 875 | ||
| 79136bb | 876 | // Web UI (catch-all, must be last) |
| 877 | app.route("/", webRoutes); | |
| 878 | ||
| c63b860 | 879 | // Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so |
| 880 | // the markup stays consistent with /500 and the admin /403 page. | |
| 79136bb | 881 | app.notFound((c) => { |
| 36cc17a | 882 | const user = c.get("user") ?? null; |
| 79136bb | 883 | return c.html( |
| c63b860 | 884 | <NotFoundPage user={user} method={c.req.method} path={c.req.path} />, |
| 79136bb | 885 | 404 |
| 886 | ); | |
| 887 | }); | |
| 888 | ||
| c63b860 | 889 | // Global error handler — BLOCK O2 uses the shared `ServerErrorPage` |
| 890 | // view. Trace block only shown outside production. | |
| 79136bb | 891 | app.onError((err, c) => { |
| 80bed05 | 892 | reportError(err, { |
| 893 | requestId: c.get("requestId"), | |
| 894 | path: c.req.path, | |
| 895 | method: c.req.method, | |
| 896 | }); | |
| c63b860 | 897 | // Prefer the inbound `x-request-id` header (LB-supplied) and fall |
| 898 | // back to the context value set by request-context middleware. | |
| 899 | const requestId = | |
| 900 | c.req.header("x-request-id") || | |
| 901 | ((c.get("requestId" as never) as string | undefined) ?? undefined); | |
| 36cc17a | 902 | const user = c.get("user") ?? null; |
| c63b860 | 903 | const trace = |
| 904 | process.env.NODE_ENV !== "production" && err && err.message | |
| 905 | ? err.message | |
| 906 | : undefined; | |
| 79136bb | 907 | return c.html( |
| c63b860 | 908 | <ServerErrorPage user={user} requestId={requestId} trace={trace} />, |
| 79136bb | 909 | 500 |
| 910 | ); | |
| 911 | }); | |
| 912 | ||
| 913 | export default app; |