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

app.tsxBlame683 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";
f1ab587Claude61import dashboardRoutes from "./routes/dashboard";
36b4cbdClaude62import legalRoutes from "./routes/legal";
4b66018Claude63import legalDmcaRoutes from "./routes/legal/dmca";
64import legalTermsRoutes from "./routes/legal/terms";
65import legalPrivacyRoutes from "./routes/legal/privacy";
66import legalAcceptableUseRoutes from "./routes/legal/acceptable-use";
bdbd0deClaude67import importRoutes from "./routes/import";
14c3cc8Claude68import importBulkRoutes from "./routes/import-bulk";
f390cfaCC LABS App69import importSecretsRoutes from "./routes/import-secrets";
14c3cc8Claude70import migrationRoutes from "./routes/migrations";
71import specsRoutes from "./routes/specs";
23d0abfClaude72import refactorRoutes from "./routes/refactors";
79136bbClaude73import webRoutes from "./routes/web";
0316dbbClaude74import hookRoutes from "./routes/hooks";
75import eventsRoutes from "./routes/events";
76import passkeyRoutes from "./routes/passkeys";
77import oauthRoutes from "./routes/oauth";
78import developerAppsRoutes from "./routes/developer-apps";
79import themeRoutes from "./routes/theme";
80import auditRoutes from "./routes/audit";
81import reactionRoutes from "./routes/reactions";
82import savedReplyRoutes from "./routes/saved-replies";
83import deploymentRoutes from "./routes/deployments";
84import orgRoutes from "./routes/orgs";
85import notificationRoutes from "./routes/notifications";
86import onboardingRoutes from "./routes/onboarding";
87import adminRoutes from "./routes/admin";
f764c07Claude88import adminDeploysRoutes from "./routes/admin-deploys";
89import adminDeploysPageRoutes from "./routes/admin-deploys-page";
783dd46Claude90import adminServerTargetsRoutes from "./routes/admin-server-targets";
90c7531Claude91import claudeWebRoutes from "./routes/claude-web";
9dd96b9Test User92import adminOpsRoutes from "./routes/admin-ops";
f2c00b4CC LABS App93import adminSelfHostRoutes from "./routes/admin-self-host";
826eccfTest User94import adminDiagnoseRoutes from "./routes/admin-diagnose";
509c376Claude95import adminIntegrationsRoutes from "./routes/admin-integrations";
79ed944Claude96import adminAdvancementRoutes from "./routes/admin-advancement";
0316dbbClaude97import advisoriesRoutes from "./routes/advisories";
98import aiChangelogRoutes from "./routes/ai-changelog";
99import aiExplainRoutes from "./routes/ai-explain";
100import aiTestsRoutes from "./routes/ai-tests";
101import askRoutes from "./routes/ask";
38d31d3Claude102import repoChatRoutes from "./routes/repo-chat";
ee7e577Claude103import personalChatRoutes from "./routes/personal-chat";
0316dbbClaude104import billingRoutes from "./routes/billing";
8809b87Claude105import billingUsageRoutes from "./routes/billing-usage";
6778ad2Claude106import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude107import codeScanningRoutes from "./routes/code-scanning";
108import commitStatusesRoutes from "./routes/commit-statuses";
109import copilotRoutes from "./routes/copilot";
110import depUpdaterRoutes from "./routes/dep-updater";
111import depsRoutes from "./routes/deps";
112import discussionsRoutes from "./routes/discussions";
113import environmentsRoutes from "./routes/environments";
4bbacbeClaude114import previewsRoutes from "./routes/previews";
79ed944Claude115import docsTrackingRoutes from "./routes/docs-tracking";
0316dbbClaude116import followsRoutes from "./routes/follows";
117import gatesRoutes from "./routes/gates";
118import gistsRoutes from "./routes/gists";
119import graphqlRoutes from "./routes/graphql";
2c2163eClaude120import mcpRoutes from "./routes/mcp";
0316dbbClaude121import marketplaceRoutes from "./routes/marketplace";
5ca514aClaude122import marketplaceAgentsRoutes from "./routes/marketplace-agents";
0316dbbClaude123import mergeQueueRoutes from "./routes/merge-queue";
124import mirrorsRoutes from "./routes/mirrors";
125import orgInsightsRoutes from "./routes/org-insights";
126import packagesRoutes from "./routes/packages";
127import packagesApiRoutes from "./routes/packages-api";
128import pagesRoutes from "./routes/pages";
129import projectsRoutes from "./routes/projects";
130import protectedTagsRoutes from "./routes/protected-tags";
131import pwaRoutes from "./routes/pwa";
46d6165Claude132import installRoutes from "./routes/install";
cd4f63bTest User133import dxtRoutes from "./routes/dxt";
662ce86Claude134import connectClaudeRoutes from "./routes/connect-claude";
ebbb527Claude135import claudeDeployRoutes from "./routes/claude-deploy";
0316dbbClaude136import releasesRoutes from "./routes/releases";
137import requiredChecksRoutes from "./routes/required-checks";
138import rulesetsRoutes from "./routes/rulesets";
139import searchRoutes from "./routes/search";
140import semanticSearchRoutes from "./routes/semantic-search";
141import signingKeysRoutes from "./routes/signing-keys";
142import sponsorsRoutes from "./routes/sponsors";
143import ssoRoutes from "./routes/sso";
46d6165Claude144import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude145import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude146import symbolsRoutes from "./routes/symbols";
147import templatesRoutes from "./routes/templates";
148import trafficRoutes from "./routes/traffic";
149import wikisRoutes from "./routes/wikis";
150import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude151import workflowArtifactsRoutes from "./routes/workflow-artifacts";
152import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude153import sleepModeRoutes from "./routes/sleep-mode";
56801e1Claude154import standupRoutes from "./routes/standups";
52ad8b1Claude155import vsGithubRoutes from "./routes/vs-github";
45f3b73Claude156import voiceRoutes from "./routes/voice-to-pr";
cd4f63bTest User157import playgroundRoutes from "./routes/playground";
59b6fb2Claude158import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
159import { csrfToken, csrfProtect } from "./middleware/csrf";
79136bbClaude160
2316901Claude161import type { AuthEnv } from "./middleware/auth";
bf19c50Test User162import { softAuth } from "./middleware/auth";
2316901Claude163
164const app = new Hono<AuthEnv>();
79136bbClaude165
3ef4c9dClaude166// Request context (request ID, start time) runs before everything else
167app.use("*", requestContext);
05b973eClaude168// Middleware — compression first (wraps all responses)
169app.use("*", compress());
f1ffd50Claude170
171// ETag middleware — returns 304 Not Modified on unchanged responses.
172// Saves ~95% bandwidth on repeat visits. Skipped on git protocol +
173// SSE + the API surface where it would interfere with streaming.
174app.use("*", async (c, next) => {
175 const p = c.req.path;
176 if (
177 p.includes(".git/") ||
178 p.startsWith("/live-events") ||
179 p.startsWith("/api/events/deploy") ||
3c03977Claude180 p.startsWith("/admin/status") ||
181 // PR live co-editing SSE stream — never etag streaming responses.
182 /^\/api\/v2\/pulls\/[^/]+\/live(\/|$)/.test(p)
f1ffd50Claude183 ) {
184 return next();
185 }
186 return etag()(c, next);
187});
188
189// Cache-Control middleware — sets sensible defaults on public, anonymous
190// requests. Crontech (when wired as our edge layer) and downstream
191// browsers will honor these. Auth'd users get private,no-store
192// automatically — we never cache responses tied to a session.
193app.use("*", async (c, next) => {
194 await next();
195 // Don't overwrite explicit headers set by route handlers — BUT the
196 // ETag middleware unconditionally sets "private, no-cache, must-
197 // revalidate" so we have to treat that specific value as "no
198 // policy chosen yet" and apply ours. Any route that explicitly set
199 // a different cache-control wins.
200 const existing = c.res.headers.get("cache-control");
201 const etagDefault =
202 existing === "private, no-cache, must-revalidate" ||
203 existing === "no-cache";
204 if (existing && !etagDefault) return;
205 // Anything past auth: private + no-store (avoid leaking session
206 // content into shared caches). softAuth runs before this on the
207 // request, but the response side is what we're stamping.
208 const hasSession = c.req.header("cookie")?.includes("session=") ?? false;
209 const p = c.req.path;
210 // Always private for known-authed paths regardless of cookie.
211 if (
212 p.startsWith("/admin") ||
213 p.startsWith("/settings") ||
214 p.startsWith("/dashboard") ||
215 p.startsWith("/notifications") ||
216 p.startsWith("/connect/") ||
217 hasSession
218 ) {
219 c.res.headers.set("cache-control", "private, no-store");
220 return;
221 }
222 // Public marketing surfaces — short edge cache, longer browser cache,
223 // stale-while-revalidate so the user never waits on a stale fetch.
224 const isMarketing =
225 p === "/" ||
226 p === "/features" ||
227 p === "/pricing" ||
228 p === "/about" ||
229 p === "/vs-github" ||
230 p === "/explore" ||
231 p === "/help" ||
232 p === "/changelog" ||
233 p.startsWith("/legal/") ||
234 p === "/terms" ||
235 p === "/privacy" ||
236 p === "/acceptable-use" ||
237 p.startsWith("/docs/");
238 if (isMarketing) {
239 c.res.headers.set(
240 "cache-control",
241 "public, max-age=60, s-maxage=300, stale-while-revalidate=86400"
242 );
243 return;
244 }
245 // Public repo browse pages — cache aggressively. Edge invalidates
246 // on push via the post-receive hook (future Crontech surge purge).
247 if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") {
248 c.res.headers.set(
249 "cache-control",
250 "public, max-age=30, s-maxage=120, stale-while-revalidate=600"
251 );
252 return;
253 }
254 // Default: don't cache anything we haven't explicitly opted in.
255 c.res.headers.set("cache-control", "private, no-store");
256});
05b973eClaude257// Logger only on non-git routes to avoid overhead on clone/push
258app.use("*", async (c, next) => {
259 if (c.req.path.includes(".git/")) return next();
260 return logger()(c, next);
261});
79136bbClaude262app.use("/api/*", cors());
bf19c50Test User263// Global softAuth — populates c.get("user") for every downstream middleware
264// + route. This was previously per-route, which meant rate-limit middleware
265// (and anything else inspecting auth state) always saw a null user. Keep
266// individual routes free to add requireAuth on top for hard gating; this
267// just establishes the user object cheaply.
268app.use("*", softAuth);
290ea77Claude269
36cc17aClaude270// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude271// pre-redesign markup. JSON / static assets keep their own cache rules; only
272// text/html responses get the no-cache stamp. Without this, every push to
273// main left users staring at cached 80s-looking pages from before the design
274// landed.
36cc17aClaude275//
276// We deliberately use `private, no-cache, must-revalidate` rather than
277// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
278// which makes every Back/Forward press a cold server round-trip — that
279// contributed to the "every nav feels like a fresh login" UX complaint.
280// `no-cache` still revalidates on direct fetch but lets bfcache hold the
281// page in memory between navigations.
290ea77Claude282app.use("*", async (c, next) => {
283 await next();
284 const ct = c.res.headers.get("content-type") || "";
285 if (ct.startsWith("text/html")) {
36cc17aClaude286 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude287 }
288});
826eccfTest User289// Rate-limit API + auth endpoints.
290//
a41e675Test User291// `/api/*`: 1000/min per IP — generous so an admin clicking around the
292// operator console (or a CDN/proxy concentrating multiple users behind one
293// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
294// rate limits below, not this one.
295//
296// `authedMultiplier` is set but only fires when an upstream middleware has
297// already populated c.get("user") — most app.use() chains apply softAuth
298// per-route, so the multiplier is best-effort. Keep the anonymous base
299// high enough that humans never feel it.
300//
301// Skip-paths: dashboard plumbing endpoints that the layout polls on a
302// fixed cadence and that we don't want consuming any bucket:
303// /api/version — layout polls every 15s
826eccfTest User304// /api/notifications/count — nav bell unread-count fetcher
305// /pwa/vapid-public-key — fetched once per push-notification opt-in
306app.use(
307 "/api/*",
a41e675Test User308 rateLimit(1000, 60_000, "api", {
826eccfTest User309 authedMultiplier: 4,
310 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
311 })
312);
0316dbbClaude313app.use("/login", rateLimit(20, 60_000, "login"));
314app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude315// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
316app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User317// BLOCK Q2 — throttle magic-link sign-in for the same reason.
318app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude319
59b6fb2Claude320// CSRF protection — set token on all requests, validate on mutations
321app.use("*", csrfToken);
322app.use("*", csrfProtect);
323
45e31d0Claude324// Rate limit auth routes
325app.use("/login", authRateLimit);
326app.use("/register", authRateLimit);
327
59b6fb2Claude328// Rate limit git operations
329app.use("/:owner/:repo.git/*", gitRateLimit);
330
331// Rate limit search
332app.use("/:owner/:repo/search", searchRateLimit);
333app.use("/explore", searchRateLimit);
79136bbClaude334
335// Git Smart HTTP protocol routes (must be before web routes)
336app.route("/", gitRoutes);
337
45e31d0Claude338// REST API v1 (legacy)
79136bbClaude339app.route("/", apiRoutes);
340
52ad8b1Claude341// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
342// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
343// router's catch-shape, and BEFORE adminRoutes so the live /demo page
344// wins over the legacy /demo redirect in src/routes/admin.tsx.
345app.route("/", demoRoutes);
346
0316dbbClaude347// REST API v2 (basePath /api/v2)
348app.route("/", apiV2Routes);
349
e75eddcClaude350// Agent multiplayer v1 — /api/v2/agents/* (sessions, leases, usage).
351// Mounted alongside apiV2Routes (its own basePath, no path conflict).
352app.route("/", agentsRoutes);
353
ad6d4adClaude354// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
355app.route("/", hookRoutes);
21f8dbdClaude356app.route("/api/events", eventsRoutes);
ad6d4adClaude357
45e31d0Claude358// API documentation
359app.route("/", apiDocsRoutes);
4a80519Claude360app.route("/", buildAgentSpecRoutes);
a6ff0f2Claude361// PR command center — global PR dashboard with AI/GateTest/auto-merge signal
362app.route("/", pullsDashboardRoutes);
e9aa4d8Claude363// Issue command center — global issue dashboard with AI-triage + autopilot signal
364app.route("/", issuesDashboardRoutes);
365// Personal activity timeline — every event across the user's repos, with
366// AI-driven events surfaced separately (the Gluecron differentiator).
367app.route("/", activityRoutes);
368// Unified inbox — mentions + review requests + CI failures + AI events in one timeline
369app.route("/", inboxRoutes);
56801e1Claude370// AI standup feed — daily / weekly Claude-generated team brief
371app.route("/", standupRoutes);
79136bbClaude372
373// Auth routes (register, login, logout)
374app.route("/", authRoutes);
375
c63b860Claude376// BLOCK P1 — Password reset (forgot-password + reset-password)
377app.route("/", passwordResetRoutes);
378
379// BLOCK P2 — Email verification (verify-email + resend)
380app.route("/", emailVerificationRoutes);
381
cd4f63bTest User382// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
383app.route("/", magicLinkRoutes);
384
79136bbClaude385// Settings routes (profile, SSH keys)
386app.route("/", settingsRoutes);
387
7298a17Claude388// 2FA / TOTP settings (Block B4)
389app.route("/", settings2faRoutes);
390
e75eddcClaude391// Agent multiplayer — /settings/agents management UI
392app.route("/", settingsAgentsRoutes);
393
1d4ff60Claude394// Chat integrations — Slack / Discord / Teams (/settings/integrations
395// + /api/v2/integrations/{slack,discord}/*). See src/lib/chat-bot.ts.
396app.route("/", settingsIntegrationsRoutes);
397app.route("/", integrationsChatRoutes);
398
2df1f8cClaude399// WebAuthn / passkey routes (Block B5)
400app.route("/", passkeyRoutes);
401
058d752Claude402// OAuth 2.0 provider (Block B6)
403app.route("/", oauthRoutes);
404app.route("/", developerAppsRoutes);
405
6fc53bdClaude406// Theme toggle (dark/light cookie)
407app.route("/", themeRoutes);
408
409// Audit log UI
410app.route("/", auditRoutes);
411
412// Reactions API (issues, PRs, comments)
413app.route("/", reactionRoutes);
414
24cf2caClaude415// Saved replies (per-user canned comment templates)
416app.route("/", savedReplyRoutes);
417
418// Environments + deployment history UI
419app.route("/", deploymentRoutes);
420
6563f0aClaude421// Organizations + teams (Block B1)
422app.route("/", orgRoutes);
423
c81ab7aClaude424// API tokens
425app.route("/", tokenRoutes);
426
59b6fb2Claude427// Notifications
3ef4c9dClaude428app.route("/", notificationRoutes);
429
79136bbClaude430// Repo settings (description, visibility, delete)
431app.route("/", repoSettings);
432
23d1a81Claude433// Repo collaborators (add/list/remove)
434app.route("/", collaboratorRoutes);
435
04f6b7fClaude436// Team-based repo collaborators (invite a whole team)
437app.route("/", teamCollaboratorRoutes);
438
439// Collaborator invite accept flow (token-based)
440app.route("/", invitesRoutes);
441
442// Real-time SSE endpoint (topic-based live updates)
443app.route("/", liveEventsRoutes);
444
3c03977Claude445// PR live co-editing — presence + cursors + content sync via SSE.
446app.route("/", prLiveRoutes);
447
c81ab7aClaude448// Webhooks management
449app.route("/", webhookRoutes);
450
79136bbClaude451// Compare view (branch diffs)
452app.route("/", compareRoutes);
453
454// Issue tracker
455app.route("/", issueRoutes);
456
cb5a796Claude457// Comment moderation queue — owner-only `/:owner/:repo/comments/pending`
458// + per-row approve/reject/spam actions. Mounted before `pullRoutes` so
459// the `/:owner/:repo/comments/*` paths resolve before the broader PR
460// patterns kick in.
461app.route("/", commentModerationRoutes);
462
0074234Claude463// Pull requests
464app.route("/", pullRoutes);
79ed944Claude465// PR sandboxes — runnable per-PR environments. Migration 0067.
466app.route("/", prSandboxRoutes);
0074234Claude467
9b3a183Claude468// Cloud dev environments — hosted VS Code in the browser. Migration 0072.
469app.route("/", devEnvRoutes);
470
c81ab7aClaude471// Fork
472app.route("/", forkRoutes);
473
0074234Claude474// Web file editor
475app.route("/", editorRoutes);
476
43de941Claude477// Contributors
478app.route("/", contributorRoutes);
479
699e5c7Claude480// Health liveness + metrics endpoints
2c34075Claude481app.route("/", healthRoutes);
482
f295f78Dictation App483// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
484app.route("/api/platform-status", platformStatus);
485
52ad8b1Claude486// Block L4 — Public stats counters (powers landing-page social proof)
487app.route("/", publicStatsRoutes);
488
489// Block L3 — Live /demo page + /api/v2/demo/* endpoints
490app.route("/", demoRoutes);
491
2316be6Claude492// Public /status — human-readable platform health page
493app.route("/", statusRoutes);
494
b1be050CC LABS App495// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
496// Mounted near the public status route so the two surfaces are visible
497// side-by-side; routes are gated by isSiteAdmin internally.
498app.route("/", adminStatusRoutes);
499
80bed05Claude500// /help — quickstart + API cheatsheet
501app.route("/", helpRoutes);
502
5f2e749Claude503// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
504// so the new editorial pricing layout wins the route; the legacy marketing
505// pricing remains as a safety net but is shadowed at the router.
506app.route("/", pricingRoutes);
507
b0148e9Claude508// /pricing, /features, /about — marketing surface
509app.route("/", marketingRoutes);
510
5618f9aClaude511// SEO: robots.txt + sitemap.xml
512app.route("/", seoRoutes);
513
05cdb85Claude514// /api/version — live build SHA + uptime; client poller uses this to
515// surface 'New version available — reload' banners on deploy.
516app.route("/", versionRoutes);
517
699e5c7Claude518// Health dashboard (per-repo health page)
519app.route("/", healthDashboardRoutes);
520
9dd96b9Test User521// Block R1 — site-admin operations console. MUST be mounted BEFORE
522// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
523// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
524app.route("/", adminOpsRoutes);
f2c00b4CC LABS App525// BLOCK W — Self-host status + bootstrap dashboard.
526app.route("/", adminSelfHostRoutes);
826eccfTest User527// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
528app.route("/", adminDiagnoseRoutes);
9dd96b9Test User529
16b325cClaude530// Insights (time-travel, dependencies, rollback)
531app.route("/", insightRoutes);
532
f1ab587Claude533// Command center dashboard
534app.route("/", dashboardRoutes);
535
36b4cbdClaude536// Legal pages (terms, privacy, AUP)
537app.route("/", legalRoutes);
4b66018Claude538// Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}.
539// The main `legal.tsx` serves the short canonical paths (/terms, /privacy,
540// /acceptable-use); these are the formal versions that the legal pages
541// internally link to each other.
542app.route("/", legalTermsRoutes);
543app.route("/", legalPrivacyRoutes);
544app.route("/", legalAcceptableUseRoutes);
545app.route("/", legalDmcaRoutes);
36b4cbdClaude546
bdbd0deClaude547// GitHub import / migration
548app.route("/", importRoutes);
14c3cc8Claude549app.route("/", importBulkRoutes);
f390cfaCC LABS App550app.route("/", importSecretsRoutes);
14c3cc8Claude551app.route("/", migrationRoutes);
552
553// Spec-to-PR (experimental AI-generated draft PRs)
554app.route("/", specsRoutes);
23d0abfClaude555app.route("/", refactorRoutes);
bdbd0deClaude556
c81ab7aClaude557// Explore page
558app.route("/", exploreRoutes);
559
59b6fb2Claude560// Onboarding
561app.route("/", onboardingRoutes);
562
0316dbbClaude563// Admin + feature routes
564app.route("/", adminRoutes);
509c376Claude565app.route("/", adminIntegrationsRoutes);
79ed944Claude566app.route("/", adminAdvancementRoutes);
f764c07Claude567app.route("/", adminDeploysRoutes);
568app.route("/", adminDeploysPageRoutes);
783dd46Claude569app.route("/", adminServerTargetsRoutes);
90c7531Claude570app.route("/", claudeWebRoutes);
9dd96b9Test User571// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude572app.route("/", advisoriesRoutes);
573app.route("/", aiChangelogRoutes);
574app.route("/", aiExplainRoutes);
575app.route("/", aiTestsRoutes);
576app.route("/", askRoutes);
38d31d3Claude577app.route("/", repoChatRoutes);
ee7e577Claude578// Personal cross-repo chat — `/chat` (user-scoped). Mounted alongside
579// repoChatRoutes so the two surfaces share the catch-all priority.
580app.route("/", personalChatRoutes);
0316dbbClaude581app.route("/", billingRoutes);
8809b87Claude582app.route("/", billingUsageRoutes);
6778ad2Claude583app.route("/", stripeWebhookRoutes);
0316dbbClaude584app.route("/", codeScanningRoutes);
585app.route("/", commitStatusesRoutes);
586app.route("/", copilotRoutes);
587app.route("/", depUpdaterRoutes);
588app.route("/", depsRoutes);
589app.route("/", discussionsRoutes);
590app.route("/", environmentsRoutes);
4bbacbeClaude591app.route("/", previewsRoutes);
79ed944Claude592app.route("/", docsTrackingRoutes);
0316dbbClaude593app.route("/", followsRoutes);
594app.route("/", gatesRoutes);
595app.route("/", gistsRoutes);
596app.route("/", graphqlRoutes);
2c2163eClaude597app.route("/", mcpRoutes);
0316dbbClaude598app.route("/", marketplaceRoutes);
5ca514aClaude599app.route("/", marketplaceAgentsRoutes);
0316dbbClaude600app.route("/", mergeQueueRoutes);
601app.route("/", mirrorsRoutes);
602app.route("/", orgInsightsRoutes);
603app.route("/", packagesRoutes);
604app.route("/", packagesApiRoutes);
605app.route("/", pagesRoutes);
606app.route("/", projectsRoutes);
607app.route("/", protectedTagsRoutes);
608app.route("/", pwaRoutes);
46d6165Claude609app.route("/", installRoutes);
cd4f63bTest User610// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
611app.route("/", dxtRoutes);
662ce86Claude612// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
613// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
614app.route("/", connectClaudeRoutes);
ebbb527Claude615// Hosted Claude tool-use loops — paste loop, get endpoint, billing meter.
616// See src/routes/claude-deploy.tsx + src/lib/hosted-claude-loop.ts.
617app.route("/", claudeDeployRoutes);
0316dbbClaude618app.route("/", releasesRoutes);
619app.route("/", requiredChecksRoutes);
620app.route("/", rulesetsRoutes);
621app.route("/", searchRoutes);
622app.route("/", semanticSearchRoutes);
623app.route("/", signingKeysRoutes);
624app.route("/", sponsorsRoutes);
625app.route("/", ssoRoutes);
46d6165Claude626app.route("/", githubOauthRoutes);
582cdacClaude627app.route("/", googleOauthRoutes);
0316dbbClaude628app.route("/", symbolsRoutes);
629app.route("/", templatesRoutes);
630app.route("/", trafficRoutes);
631app.route("/", wikisRoutes);
632app.route("/", workflowsRoutes);
5ff9cc2Claude633app.route("/", workflowArtifactsRoutes);
634app.route("/", workflowSecretsRoutes);
46d6165Claude635app.route("/", sleepModeRoutes);
52ad8b1Claude636app.route("/", vsGithubRoutes);
0316dbbClaude637
45f3b73Claude638// Voice-to-PR — phone-first dictation → spec or issue
639app.route("/", voiceRoutes);
640
cd4f63bTest User641// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
642// before the web catch-all so the bare `/play` literal wins over the
643// `/:owner` user-profile route.
644app.route("/", playgroundRoutes);
645
79136bbClaude646// Web UI (catch-all, must be last)
647app.route("/", webRoutes);
648
c63b860Claude649// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
650// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude651app.notFound((c) => {
36cc17aClaude652 const user = c.get("user") ?? null;
79136bbClaude653 return c.html(
c63b860Claude654 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude655 404
656 );
657});
658
c63b860Claude659// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
660// view. Trace block only shown outside production.
79136bbClaude661app.onError((err, c) => {
80bed05Claude662 reportError(err, {
663 requestId: c.get("requestId"),
664 path: c.req.path,
665 method: c.req.method,
666 });
c63b860Claude667 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
668 // back to the context value set by request-context middleware.
669 const requestId =
670 c.req.header("x-request-id") ||
671 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude672 const user = c.get("user") ?? null;
c63b860Claude673 const trace =
674 process.env.NODE_ENV !== "production" && err && err.message
675 ? err.message
676 : undefined;
79136bbClaude677 return c.html(
c63b860Claude678 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude679 500
680 );
681});
682
683export default app;