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