Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesPull RequestsActionsSecurityInsightsSettings
✨ AI
More
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.

app.tsxBlame705 lines · 4 contributors
79136bbClaude1import { Hono } from "hono";
2import { logger } from "hono/logger";
3import { cors } from "hono/cors";
05b973eClaude4import { compress } from "hono/compress";
f1ffd50Claude5import { etag } from "hono/etag";
c63b860Claude6// BLOCK O2 — shared error-page surface (404 / 500 / 403).
7import { NotFoundPage, ServerErrorPage } from "./views/error-page";
80bed05Claude8import { reportError } from "./lib/observability";
3ef4c9dClaude9import { requestContext } from "./middleware/request-context";
10import { rateLimit } from "./middleware/rate-limit";
79136bbClaude11import gitRoutes from "./routes/git";
12import apiRoutes from "./routes/api";
45e31d0Claude13import apiV2Routes from "./routes/api-v2";
14import apiDocsRoutes from "./routes/api-docs";
4a80519Claude15import buildAgentSpecRoutes from "./routes/build-agent-spec";
a6ff0f2Claude16import pullsDashboardRoutes from "./routes/pulls-dashboard";
e9aa4d8Claude17import issuesDashboardRoutes from "./routes/issues-dashboard";
18import inboxRoutes from "./routes/inbox";
19import activityRoutes from "./routes/activity";
79136bbClaude20import authRoutes from "./routes/auth";
c63b860Claude21import passwordResetRoutes from "./routes/password-reset";
22import emailVerificationRoutes from "./routes/email-verification";
cd4f63bTest User23import magicLinkRoutes from "./routes/magic-link";
79136bbClaude24import settingsRoutes from "./routes/settings";
7298a17Claude25import settings2faRoutes from "./routes/settings-2fa";
e75eddcClaude26import settingsAgentsRoutes from "./routes/settings-agents";
1d4ff60Claude27import settingsIntegrationsRoutes from "./routes/settings-integrations";
28import integrationsChatRoutes from "./routes/integrations-chat";
e75eddcClaude29import agentsRoutes from "./routes/agents";
79136bbClaude30import issueRoutes from "./routes/issues";
cb5a796Claude31import commentModerationRoutes from "./routes/comment-moderation";
79136bbClaude32import repoSettings from "./routes/repo-settings";
23d1a81Claude33import collaboratorRoutes from "./routes/collaborators";
04f6b7fClaude34import teamCollaboratorRoutes from "./routes/team-collaborators";
35import invitesRoutes from "./routes/invites";
36import liveEventsRoutes from "./routes/live-events";
3c03977Claude37import prLiveRoutes from "./routes/pr-live";
79136bbClaude38import compareRoutes from "./routes/compare";
0074234Claude39import pullRoutes from "./routes/pulls";
79ed944Claude40import prSandboxRoutes from "./routes/pr-sandbox";
9b3a183Claude41import devEnvRoutes from "./routes/dev-env";
0074234Claude42import editorRoutes from "./routes/editor";
c81ab7aClaude43import forkRoutes from "./routes/fork";
44import webhookRoutes from "./routes/webhooks";
45import exploreRoutes from "./routes/explore";
46import tokenRoutes from "./routes/tokens";
43de941Claude47import contributorRoutes from "./routes/contributors";
699e5c7Claude48import healthRoutes from "./routes/health-probe";
49import healthDashboardRoutes from "./routes/health";
2316be6Claude50import statusRoutes from "./routes/status";
b1be050CC LABS App51import adminStatusRoutes from "./routes/admin-status";
80bed05Claude52import helpRoutes from "./routes/help";
b0148e9Claude53import marketingRoutes from "./routes/marketing";
5f2e749Claude54import pricingRoutes from "./routes/pricing";
5618f9aClaude55import seoRoutes from "./routes/seo";
05cdb85Claude56import versionRoutes from "./routes/version";
f295f78Dictation App57import { platformStatus } from "./routes/platform-status";
52ad8b1Claude58import publicStatsRoutes from "./routes/public-stats";
59import demoRoutes from "./routes/demo";
16b325cClaude60import insightRoutes from "./routes/insights";
8d1483cClaude61import doraRoutes from "./routes/dora";
f1ab587Claude62import dashboardRoutes from "./routes/dashboard";
36b4cbdClaude63import legalRoutes from "./routes/legal";
4b66018Claude64import legalDmcaRoutes from "./routes/legal/dmca";
65import legalTermsRoutes from "./routes/legal/terms";
66import legalPrivacyRoutes from "./routes/legal/privacy";
67import legalAcceptableUseRoutes from "./routes/legal/acceptable-use";
bdbd0deClaude68import importRoutes from "./routes/import";
14c3cc8Claude69import importBulkRoutes from "./routes/import-bulk";
f390cfaCC LABS App70import importSecretsRoutes from "./routes/import-secrets";
14c3cc8Claude71import migrationRoutes from "./routes/migrations";
72import specsRoutes from "./routes/specs";
23d0abfClaude73import refactorRoutes from "./routes/refactors";
79136bbClaude74import webRoutes from "./routes/web";
0316dbbClaude75import hookRoutes from "./routes/hooks";
76import eventsRoutes from "./routes/events";
77import passkeyRoutes from "./routes/passkeys";
78import oauthRoutes from "./routes/oauth";
79import developerAppsRoutes from "./routes/developer-apps";
80import themeRoutes from "./routes/theme";
81import auditRoutes from "./routes/audit";
82import reactionRoutes from "./routes/reactions";
83import savedReplyRoutes from "./routes/saved-replies";
84import deploymentRoutes from "./routes/deployments";
85import orgRoutes from "./routes/orgs";
86import notificationRoutes from "./routes/notifications";
87import onboardingRoutes from "./routes/onboarding";
88import adminRoutes from "./routes/admin";
f764c07Claude89import adminDeploysRoutes from "./routes/admin-deploys";
90import adminDeploysPageRoutes from "./routes/admin-deploys-page";
783dd46Claude91import adminServerTargetsRoutes from "./routes/admin-server-targets";
90c7531Claude92import claudeWebRoutes from "./routes/claude-web";
9dd96b9Test User93import adminOpsRoutes from "./routes/admin-ops";
f2c00b4CC LABS App94import adminSelfHostRoutes from "./routes/admin-self-host";
826eccfTest User95import adminDiagnoseRoutes from "./routes/admin-diagnose";
509c376Claude96import adminIntegrationsRoutes from "./routes/admin-integrations";
79ed944Claude97import adminAdvancementRoutes from "./routes/admin-advancement";
0316dbbClaude98import advisoriesRoutes from "./routes/advisories";
99import aiChangelogRoutes from "./routes/ai-changelog";
100import aiExplainRoutes from "./routes/ai-explain";
101import aiTestsRoutes from "./routes/ai-tests";
102import askRoutes from "./routes/ask";
38d31d3Claude103import repoChatRoutes from "./routes/repo-chat";
ee7e577Claude104import personalChatRoutes from "./routes/personal-chat";
0316dbbClaude105import billingRoutes from "./routes/billing";
8809b87Claude106import billingUsageRoutes from "./routes/billing-usage";
6778ad2Claude107import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude108import codeScanningRoutes from "./routes/code-scanning";
109import commitStatusesRoutes from "./routes/commit-statuses";
110import copilotRoutes from "./routes/copilot";
111import depUpdaterRoutes from "./routes/dep-updater";
112import depsRoutes from "./routes/deps";
113import discussionsRoutes from "./routes/discussions";
114import environmentsRoutes from "./routes/environments";
4bbacbeClaude115import previewsRoutes from "./routes/previews";
79ed944Claude116import docsTrackingRoutes from "./routes/docs-tracking";
0316dbbClaude117import followsRoutes from "./routes/follows";
118import gatesRoutes from "./routes/gates";
119import gistsRoutes from "./routes/gists";
120import graphqlRoutes from "./routes/graphql";
2c2163eClaude121import mcpRoutes from "./routes/mcp";
0316dbbClaude122import marketplaceRoutes from "./routes/marketplace";
5ca514aClaude123import marketplaceAgentsRoutes from "./routes/marketplace-agents";
0316dbbClaude124import mergeQueueRoutes from "./routes/merge-queue";
125import mirrorsRoutes from "./routes/mirrors";
126import orgInsightsRoutes from "./routes/org-insights";
127import packagesRoutes from "./routes/packages";
128import packagesApiRoutes from "./routes/packages-api";
129import pagesRoutes from "./routes/pages";
130import projectsRoutes from "./routes/projects";
131import protectedTagsRoutes from "./routes/protected-tags";
132import pwaRoutes from "./routes/pwa";
46d6165Claude133import installRoutes from "./routes/install";
cd4f63bTest User134import dxtRoutes from "./routes/dxt";
662ce86Claude135import connectClaudeRoutes from "./routes/connect-claude";
ebbb527Claude136import claudeDeployRoutes from "./routes/claude-deploy";
f5b9ef5Claude137import claudeIntegration from "./routes/claude-integration";
138import connectRoutes from "./routes/connect";
05ab9b1Claude139import pushWatchRoutes from "./routes/push-watch";
140import orgSecretsRoutes from "./routes/org-secrets";
0316dbbClaude141import releasesRoutes from "./routes/releases";
142import requiredChecksRoutes from "./routes/required-checks";
143import rulesetsRoutes from "./routes/rulesets";
144import searchRoutes from "./routes/search";
145import semanticSearchRoutes from "./routes/semantic-search";
146import signingKeysRoutes from "./routes/signing-keys";
147import sponsorsRoutes from "./routes/sponsors";
148import ssoRoutes from "./routes/sso";
46d6165Claude149import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude150import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude151import symbolsRoutes from "./routes/symbols";
152import templatesRoutes from "./routes/templates";
153import trafficRoutes from "./routes/traffic";
154import wikisRoutes from "./routes/wikis";
155import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude156import workflowArtifactsRoutes from "./routes/workflow-artifacts";
157import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude158import sleepModeRoutes from "./routes/sleep-mode";
56801e1Claude159import standupRoutes from "./routes/standups";
52ad8b1Claude160import vsGithubRoutes from "./routes/vs-github";
45f3b73Claude161import voiceRoutes from "./routes/voice-to-pr";
cd4f63bTest User162import playgroundRoutes from "./routes/playground";
59b6fb2Claude163import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
164import { csrfToken, csrfProtect } from "./middleware/csrf";
f5b9ef5Claude165import { noCache } from "./middleware/no-cache";
79136bbClaude166
2316901Claude167import type { AuthEnv } from "./middleware/auth";
bf19c50Test User168import { softAuth } from "./middleware/auth";
2316901Claude169
170const app = new Hono<AuthEnv>();
79136bbClaude171
3ef4c9dClaude172// Request context (request ID, start time) runs before everything else
173app.use("*", requestContext);
05b973eClaude174// Middleware — compression first (wraps all responses)
175app.use("*", compress());
f1ffd50Claude176
177// ETag middleware — returns 304 Not Modified on unchanged responses.
178// Saves ~95% bandwidth on repeat visits. Skipped on git protocol +
179// SSE + the API surface where it would interfere with streaming.
180app.use("*", async (c, next) => {
181 const p = c.req.path;
182 if (
183 p.includes(".git/") ||
184 p.startsWith("/live-events") ||
185 p.startsWith("/api/events/deploy") ||
3c03977Claude186 p.startsWith("/admin/status") ||
187 // PR live co-editing SSE stream — never etag streaming responses.
188 /^\/api\/v2\/pulls\/[^/]+\/live(\/|$)/.test(p)
f1ffd50Claude189 ) {
190 return next();
191 }
192 return etag()(c, next);
193});
194
195// Cache-Control middleware — sets sensible defaults on public, anonymous
196// requests. Crontech (when wired as our edge layer) and downstream
197// browsers will honor these. Auth'd users get private,no-store
198// automatically — we never cache responses tied to a session.
199app.use("*", async (c, next) => {
200 await next();
201 // Don't overwrite explicit headers set by route handlers — BUT the
202 // ETag middleware unconditionally sets "private, no-cache, must-
203 // revalidate" so we have to treat that specific value as "no
204 // policy chosen yet" and apply ours. Any route that explicitly set
205 // a different cache-control wins.
206 const existing = c.res.headers.get("cache-control");
207 const etagDefault =
208 existing === "private, no-cache, must-revalidate" ||
209 existing === "no-cache";
210 if (existing && !etagDefault) return;
211 // Anything past auth: private + no-store (avoid leaking session
212 // content into shared caches). softAuth runs before this on the
213 // request, but the response side is what we're stamping.
214 const hasSession = c.req.header("cookie")?.includes("session=") ?? false;
215 const p = c.req.path;
216 // Always private for known-authed paths regardless of cookie.
217 if (
218 p.startsWith("/admin") ||
219 p.startsWith("/settings") ||
220 p.startsWith("/dashboard") ||
221 p.startsWith("/notifications") ||
222 p.startsWith("/connect/") ||
223 hasSession
224 ) {
225 c.res.headers.set("cache-control", "private, no-store");
226 return;
227 }
228 // Public marketing surfaces — short edge cache, longer browser cache,
229 // stale-while-revalidate so the user never waits on a stale fetch.
230 const isMarketing =
231 p === "/" ||
232 p === "/features" ||
233 p === "/pricing" ||
234 p === "/about" ||
235 p === "/vs-github" ||
236 p === "/explore" ||
237 p === "/help" ||
238 p === "/changelog" ||
239 p.startsWith("/legal/") ||
240 p === "/terms" ||
241 p === "/privacy" ||
242 p === "/acceptable-use" ||
243 p.startsWith("/docs/");
244 if (isMarketing) {
245 c.res.headers.set(
246 "cache-control",
247 "public, max-age=60, s-maxage=300, stale-while-revalidate=86400"
248 );
249 return;
250 }
251 // Public repo browse pages — cache aggressively. Edge invalidates
252 // on push via the post-receive hook (future Crontech surge purge).
253 if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") {
254 c.res.headers.set(
255 "cache-control",
256 "public, max-age=30, s-maxage=120, stale-while-revalidate=600"
257 );
258 return;
259 }
260 // Default: don't cache anything we haven't explicitly opted in.
261 c.res.headers.set("cache-control", "private, no-store");
262});
05b973eClaude263// Logger only on non-git routes to avoid overhead on clone/push
264app.use("*", async (c, next) => {
265 if (c.req.path.includes(".git/")) return next();
266 return logger()(c, next);
267});
79136bbClaude268app.use("/api/*", cors());
bf19c50Test User269// Global softAuth — populates c.get("user") for every downstream middleware
270// + route. This was previously per-route, which meant rate-limit middleware
271// (and anything else inspecting auth state) always saw a null user. Keep
272// individual routes free to add requireAuth on top for hard gating; this
273// just establishes the user object cheaply.
274app.use("*", softAuth);
290ea77Claude275
36cc17aClaude276// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude277// pre-redesign markup. JSON / static assets keep their own cache rules; only
278// text/html responses get the no-cache stamp. Without this, every push to
279// main left users staring at cached 80s-looking pages from before the design
280// landed.
36cc17aClaude281//
282// We deliberately use `private, no-cache, must-revalidate` rather than
283// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
284// which makes every Back/Forward press a cold server round-trip — that
285// contributed to the "every nav feels like a fresh login" UX complaint.
286// `no-cache` still revalidates on direct fetch but lets bfcache hold the
287// page in memory between navigations.
290ea77Claude288app.use("*", async (c, next) => {
289 await next();
290 const ct = c.res.headers.get("content-type") || "";
291 if (ct.startsWith("text/html")) {
36cc17aClaude292 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude293 }
294});
826eccfTest User295// Rate-limit API + auth endpoints.
296//
a41e675Test User297// `/api/*`: 1000/min per IP — generous so an admin clicking around the
298// operator console (or a CDN/proxy concentrating multiple users behind one
299// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
300// rate limits below, not this one.
301//
302// `authedMultiplier` is set but only fires when an upstream middleware has
303// already populated c.get("user") — most app.use() chains apply softAuth
304// per-route, so the multiplier is best-effort. Keep the anonymous base
305// high enough that humans never feel it.
306//
307// Skip-paths: dashboard plumbing endpoints that the layout polls on a
308// fixed cadence and that we don't want consuming any bucket:
309// /api/version — layout polls every 15s
826eccfTest User310// /api/notifications/count — nav bell unread-count fetcher
311// /pwa/vapid-public-key — fetched once per push-notification opt-in
312app.use(
313 "/api/*",
a41e675Test User314 rateLimit(1000, 60_000, "api", {
826eccfTest User315 authedMultiplier: 4,
316 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
317 })
318);
0316dbbClaude319app.use("/login", rateLimit(20, 60_000, "login"));
320app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude321// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
322app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User323// BLOCK Q2 — throttle magic-link sign-in for the same reason.
324app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude325
59b6fb2Claude326// CSRF protection — set token on all requests, validate on mutations
327app.use("*", csrfToken);
328app.use("*", csrfProtect);
329
45e31d0Claude330// Rate limit auth routes
331app.use("/login", authRateLimit);
332app.use("/register", authRateLimit);
333
59b6fb2Claude334// Rate limit git operations
335app.use("/:owner/:repo.git/*", gitRateLimit);
336
337// Rate limit search
338app.use("/:owner/:repo/search", searchRateLimit);
339app.use("/explore", searchRateLimit);
79136bbClaude340
f5b9ef5Claude341// No-cache for HTML — ensures browsers and proxies never serve stale pages.
342// The middleware only stamps text/html responses so static assets keep
343// their own cache policies unchanged.
344app.use("*", noCache);
345
79136bbClaude346// Git Smart HTTP protocol routes (must be before web routes)
347app.route("/", gitRoutes);
348
45e31d0Claude349// REST API v1 (legacy)
79136bbClaude350app.route("/", apiRoutes);
351
52ad8b1Claude352// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
353// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
354// router's catch-shape, and BEFORE adminRoutes so the live /demo page
355// wins over the legacy /demo redirect in src/routes/admin.tsx.
356app.route("/", demoRoutes);
357
0316dbbClaude358// REST API v2 (basePath /api/v2)
359app.route("/", apiV2Routes);
360
e75eddcClaude361// Agent multiplayer v1 — /api/v2/agents/* (sessions, leases, usage).
362// Mounted alongside apiV2Routes (its own basePath, no path conflict).
363app.route("/", agentsRoutes);
364
ad6d4adClaude365// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
366app.route("/", hookRoutes);
21f8dbdClaude367app.route("/api/events", eventsRoutes);
ad6d4adClaude368
45e31d0Claude369// API documentation
370app.route("/", apiDocsRoutes);
4a80519Claude371app.route("/", buildAgentSpecRoutes);
a6ff0f2Claude372// PR command center — global PR dashboard with AI/GateTest/auto-merge signal
373app.route("/", pullsDashboardRoutes);
e9aa4d8Claude374// Issue command center — global issue dashboard with AI-triage + autopilot signal
375app.route("/", issuesDashboardRoutes);
376// Personal activity timeline — every event across the user's repos, with
377// AI-driven events surfaced separately (the Gluecron differentiator).
378app.route("/", activityRoutes);
379// Unified inbox — mentions + review requests + CI failures + AI events in one timeline
380app.route("/", inboxRoutes);
56801e1Claude381// AI standup feed — daily / weekly Claude-generated team brief
382app.route("/", standupRoutes);
79136bbClaude383
384// Auth routes (register, login, logout)
385app.route("/", authRoutes);
386
c63b860Claude387// BLOCK P1 — Password reset (forgot-password + reset-password)
388app.route("/", passwordResetRoutes);
389
390// BLOCK P2 — Email verification (verify-email + resend)
391app.route("/", emailVerificationRoutes);
392
cd4f63bTest User393// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
394app.route("/", magicLinkRoutes);
395
79136bbClaude396// Settings routes (profile, SSH keys)
397app.route("/", settingsRoutes);
398
7298a17Claude399// 2FA / TOTP settings (Block B4)
400app.route("/", settings2faRoutes);
401
e75eddcClaude402// Agent multiplayer — /settings/agents management UI
403app.route("/", settingsAgentsRoutes);
404
1d4ff60Claude405// Chat integrations — Slack / Discord / Teams (/settings/integrations
406// + /api/v2/integrations/{slack,discord}/*). See src/lib/chat-bot.ts.
407app.route("/", settingsIntegrationsRoutes);
408app.route("/", integrationsChatRoutes);
409
2df1f8cClaude410// WebAuthn / passkey routes (Block B5)
411app.route("/", passkeyRoutes);
412
058d752Claude413// OAuth 2.0 provider (Block B6)
414app.route("/", oauthRoutes);
415app.route("/", developerAppsRoutes);
416
6fc53bdClaude417// Theme toggle (dark/light cookie)
418app.route("/", themeRoutes);
419
420// Audit log UI
421app.route("/", auditRoutes);
422
423// Reactions API (issues, PRs, comments)
424app.route("/", reactionRoutes);
425
24cf2caClaude426// Saved replies (per-user canned comment templates)
427app.route("/", savedReplyRoutes);
428
429// Environments + deployment history UI
430app.route("/", deploymentRoutes);
431
6563f0aClaude432// Organizations + teams (Block B1)
433app.route("/", orgRoutes);
434
c81ab7aClaude435// API tokens
436app.route("/", tokenRoutes);
437
59b6fb2Claude438// Notifications
3ef4c9dClaude439app.route("/", notificationRoutes);
440
79136bbClaude441// Repo settings (description, visibility, delete)
442app.route("/", repoSettings);
443
23d1a81Claude444// Repo collaborators (add/list/remove)
445app.route("/", collaboratorRoutes);
446
04f6b7fClaude447// Team-based repo collaborators (invite a whole team)
448app.route("/", teamCollaboratorRoutes);
449
450// Collaborator invite accept flow (token-based)
451app.route("/", invitesRoutes);
452
453// Real-time SSE endpoint (topic-based live updates)
454app.route("/", liveEventsRoutes);
455
3c03977Claude456// PR live co-editing — presence + cursors + content sync via SSE.
457app.route("/", prLiveRoutes);
458
c81ab7aClaude459// Webhooks management
460app.route("/", webhookRoutes);
461
79136bbClaude462// Compare view (branch diffs)
463app.route("/", compareRoutes);
464
465// Issue tracker
466app.route("/", issueRoutes);
467
cb5a796Claude468// Comment moderation queue — owner-only `/:owner/:repo/comments/pending`
469// + per-row approve/reject/spam actions. Mounted before `pullRoutes` so
470// the `/:owner/:repo/comments/*` paths resolve before the broader PR
471// patterns kick in.
472app.route("/", commentModerationRoutes);
473
0074234Claude474// Pull requests
475app.route("/", pullRoutes);
79ed944Claude476// PR sandboxes — runnable per-PR environments. Migration 0067.
477app.route("/", prSandboxRoutes);
0074234Claude478
9b3a183Claude479// Cloud dev environments — hosted VS Code in the browser. Migration 0072.
480app.route("/", devEnvRoutes);
481
c81ab7aClaude482// Fork
483app.route("/", forkRoutes);
484
0074234Claude485// Web file editor
486app.route("/", editorRoutes);
487
43de941Claude488// Contributors
489app.route("/", contributorRoutes);
490
699e5c7Claude491// Health liveness + metrics endpoints
2c34075Claude492app.route("/", healthRoutes);
493
f295f78Dictation App494// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
495app.route("/api/platform-status", platformStatus);
496
52ad8b1Claude497// Block L4 — Public stats counters (powers landing-page social proof)
498app.route("/", publicStatsRoutes);
499
500// Block L3 — Live /demo page + /api/v2/demo/* endpoints
501app.route("/", demoRoutes);
502
2316be6Claude503// Public /status — human-readable platform health page
504app.route("/", statusRoutes);
505
b1be050CC LABS App506// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
507// Mounted near the public status route so the two surfaces are visible
508// side-by-side; routes are gated by isSiteAdmin internally.
509app.route("/", adminStatusRoutes);
510
80bed05Claude511// /help — quickstart + API cheatsheet
512app.route("/", helpRoutes);
513
5f2e749Claude514// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
515// so the new editorial pricing layout wins the route; the legacy marketing
516// pricing remains as a safety net but is shadowed at the router.
517app.route("/", pricingRoutes);
518
b0148e9Claude519// /pricing, /features, /about — marketing surface
520app.route("/", marketingRoutes);
521
5618f9aClaude522// SEO: robots.txt + sitemap.xml
523app.route("/", seoRoutes);
524
05cdb85Claude525// /api/version — live build SHA + uptime; client poller uses this to
526// surface 'New version available — reload' banners on deploy.
527app.route("/", versionRoutes);
528
699e5c7Claude529// Health dashboard (per-repo health page)
530app.route("/", healthDashboardRoutes);
531
9dd96b9Test User532// Block R1 — site-admin operations console. MUST be mounted BEFORE
533// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
534// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
535app.route("/", adminOpsRoutes);
f2c00b4CC LABS App536// BLOCK W — Self-host status + bootstrap dashboard.
537app.route("/", adminSelfHostRoutes);
826eccfTest User538// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
539app.route("/", adminDiagnoseRoutes);
9dd96b9Test User540
16b325cClaude541// Insights (time-travel, dependencies, rollback)
542app.route("/", insightRoutes);
543
8d1483cClaude544// DORA metrics page (/:owner/:repo/insights/dora)
545app.route("/", doraRoutes);
546
f1ab587Claude547// Command center dashboard
548app.route("/", dashboardRoutes);
549
36b4cbdClaude550// Legal pages (terms, privacy, AUP)
551app.route("/", legalRoutes);
4b66018Claude552// Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}.
553// The main `legal.tsx` serves the short canonical paths (/terms, /privacy,
554// /acceptable-use); these are the formal versions that the legal pages
555// internally link to each other.
556app.route("/", legalTermsRoutes);
557app.route("/", legalPrivacyRoutes);
558app.route("/", legalAcceptableUseRoutes);
559app.route("/", legalDmcaRoutes);
36b4cbdClaude560
bdbd0deClaude561// GitHub import / migration
562app.route("/", importRoutes);
14c3cc8Claude563app.route("/", importBulkRoutes);
f390cfaCC LABS App564app.route("/", importSecretsRoutes);
14c3cc8Claude565app.route("/", migrationRoutes);
566
567// Spec-to-PR (experimental AI-generated draft PRs)
568app.route("/", specsRoutes);
23d0abfClaude569app.route("/", refactorRoutes);
bdbd0deClaude570
c81ab7aClaude571// Explore page
572app.route("/", exploreRoutes);
573
59b6fb2Claude574// Onboarding
575app.route("/", onboardingRoutes);
576
0316dbbClaude577// Admin + feature routes
578app.route("/", adminRoutes);
509c376Claude579app.route("/", adminIntegrationsRoutes);
79ed944Claude580app.route("/", adminAdvancementRoutes);
f764c07Claude581app.route("/", adminDeploysRoutes);
582app.route("/", adminDeploysPageRoutes);
783dd46Claude583app.route("/", adminServerTargetsRoutes);
90c7531Claude584app.route("/", claudeWebRoutes);
9dd96b9Test User585// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude586app.route("/", advisoriesRoutes);
587app.route("/", aiChangelogRoutes);
588app.route("/", aiExplainRoutes);
589app.route("/", aiTestsRoutes);
590app.route("/", askRoutes);
38d31d3Claude591app.route("/", repoChatRoutes);
ee7e577Claude592// Personal cross-repo chat — `/chat` (user-scoped). Mounted alongside
593// repoChatRoutes so the two surfaces share the catch-all priority.
594app.route("/", personalChatRoutes);
0316dbbClaude595app.route("/", billingRoutes);
8809b87Claude596app.route("/", billingUsageRoutes);
6778ad2Claude597app.route("/", stripeWebhookRoutes);
0316dbbClaude598app.route("/", codeScanningRoutes);
599app.route("/", commitStatusesRoutes);
600app.route("/", copilotRoutes);
601app.route("/", depUpdaterRoutes);
602app.route("/", depsRoutes);
603app.route("/", discussionsRoutes);
604app.route("/", environmentsRoutes);
4bbacbeClaude605app.route("/", previewsRoutes);
79ed944Claude606app.route("/", docsTrackingRoutes);
0316dbbClaude607app.route("/", followsRoutes);
608app.route("/", gatesRoutes);
609app.route("/", gistsRoutes);
610app.route("/", graphqlRoutes);
2c2163eClaude611app.route("/", mcpRoutes);
0316dbbClaude612app.route("/", marketplaceRoutes);
5ca514aClaude613app.route("/", marketplaceAgentsRoutes);
0316dbbClaude614app.route("/", mergeQueueRoutes);
615app.route("/", mirrorsRoutes);
616app.route("/", orgInsightsRoutes);
617app.route("/", packagesRoutes);
618app.route("/", packagesApiRoutes);
619app.route("/", pagesRoutes);
620app.route("/", projectsRoutes);
621app.route("/", protectedTagsRoutes);
622app.route("/", pwaRoutes);
46d6165Claude623app.route("/", installRoutes);
cd4f63bTest User624// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
625app.route("/", dxtRoutes);
662ce86Claude626// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
627// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
628app.route("/", connectClaudeRoutes);
f5b9ef5Claude629// Claude Code Integration Receiver — /api/claude/connect + /api/claude/session.
630app.route("/", claudeIntegration);
631// Connect guide — public onboarding page (/connect/claude-guide).
632app.route("/", connectRoutes);
05ab9b1Claude633// Push Watch — per-commit live status (gates + deploy + latency) at /:owner/:repo/push/:sha
634app.route("/", pushWatchRoutes);
635// Org Secrets Manager — BLOCK M2 — /orgs/:slug/settings/secrets
636app.route("/", orgSecretsRoutes);
ebbb527Claude637// Hosted Claude tool-use loops — paste loop, get endpoint, billing meter.
638// See src/routes/claude-deploy.tsx + src/lib/hosted-claude-loop.ts.
639app.route("/", claudeDeployRoutes);
0316dbbClaude640app.route("/", releasesRoutes);
641app.route("/", requiredChecksRoutes);
642app.route("/", rulesetsRoutes);
643app.route("/", searchRoutes);
644app.route("/", semanticSearchRoutes);
645app.route("/", signingKeysRoutes);
646app.route("/", sponsorsRoutes);
647app.route("/", ssoRoutes);
46d6165Claude648app.route("/", githubOauthRoutes);
582cdacClaude649app.route("/", googleOauthRoutes);
0316dbbClaude650app.route("/", symbolsRoutes);
651app.route("/", templatesRoutes);
652app.route("/", trafficRoutes);
653app.route("/", wikisRoutes);
654app.route("/", workflowsRoutes);
5ff9cc2Claude655app.route("/", workflowArtifactsRoutes);
656app.route("/", workflowSecretsRoutes);
46d6165Claude657app.route("/", sleepModeRoutes);
52ad8b1Claude658app.route("/", vsGithubRoutes);
0316dbbClaude659
45f3b73Claude660// Voice-to-PR — phone-first dictation → spec or issue
661app.route("/", voiceRoutes);
662
cd4f63bTest User663// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
664// before the web catch-all so the bare `/play` literal wins over the
665// `/:owner` user-profile route.
666app.route("/", playgroundRoutes);
667
79136bbClaude668// Web UI (catch-all, must be last)
669app.route("/", webRoutes);
670
c63b860Claude671// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
672// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude673app.notFound((c) => {
36cc17aClaude674 const user = c.get("user") ?? null;
79136bbClaude675 return c.html(
c63b860Claude676 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude677 404
678 );
679});
680
c63b860Claude681// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
682// view. Trace block only shown outside production.
79136bbClaude683app.onError((err, c) => {
80bed05Claude684 reportError(err, {
685 requestId: c.get("requestId"),
686 path: c.req.path,
687 method: c.req.method,
688 });
c63b860Claude689 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
690 // back to the context value set by request-context middleware.
691 const requestId =
692 c.req.header("x-request-id") ||
693 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude694 const user = c.get("user") ?? null;
c63b860Claude695 const trace =
696 process.env.NODE_ENV !== "production" && err && err.message
697 ? err.message
698 : undefined;
79136bbClaude699 return c.html(
c63b860Claude700 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude701 500
702 );
703});
704
705export default app;