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.tsxBlame671 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";
0074234Claude41import editorRoutes from "./routes/editor";
c81ab7aClaude42import forkRoutes from "./routes/fork";
43import webhookRoutes from "./routes/webhooks";
44import exploreRoutes from "./routes/explore";
45import tokenRoutes from "./routes/tokens";
43de941Claude46import contributorRoutes from "./routes/contributors";
699e5c7Claude47import healthRoutes from "./routes/health-probe";
48import healthDashboardRoutes from "./routes/health";
2316be6Claude49import statusRoutes from "./routes/status";
b1be050CC LABS App50import adminStatusRoutes from "./routes/admin-status";
80bed05Claude51import helpRoutes from "./routes/help";
b0148e9Claude52import marketingRoutes from "./routes/marketing";
5f2e749Claude53import pricingRoutes from "./routes/pricing";
5618f9aClaude54import seoRoutes from "./routes/seo";
05cdb85Claude55import versionRoutes from "./routes/version";
f295f78Dictation App56import { platformStatus } from "./routes/platform-status";
52ad8b1Claude57import publicStatsRoutes from "./routes/public-stats";
58import demoRoutes from "./routes/demo";
16b325cClaude59import insightRoutes from "./routes/insights";
f1ab587Claude60import dashboardRoutes from "./routes/dashboard";
36b4cbdClaude61import legalRoutes from "./routes/legal";
4b66018Claude62import legalDmcaRoutes from "./routes/legal/dmca";
63import legalTermsRoutes from "./routes/legal/terms";
64import legalPrivacyRoutes from "./routes/legal/privacy";
65import legalAcceptableUseRoutes from "./routes/legal/acceptable-use";
bdbd0deClaude66import importRoutes from "./routes/import";
14c3cc8Claude67import importBulkRoutes from "./routes/import-bulk";
f390cfaCC LABS App68import importSecretsRoutes from "./routes/import-secrets";
14c3cc8Claude69import migrationRoutes from "./routes/migrations";
70import specsRoutes from "./routes/specs";
23d0abfClaude71import refactorRoutes from "./routes/refactors";
79136bbClaude72import webRoutes from "./routes/web";
0316dbbClaude73import hookRoutes from "./routes/hooks";
74import eventsRoutes from "./routes/events";
75import passkeyRoutes from "./routes/passkeys";
76import oauthRoutes from "./routes/oauth";
77import developerAppsRoutes from "./routes/developer-apps";
78import themeRoutes from "./routes/theme";
79import auditRoutes from "./routes/audit";
80import reactionRoutes from "./routes/reactions";
81import savedReplyRoutes from "./routes/saved-replies";
82import deploymentRoutes from "./routes/deployments";
83import orgRoutes from "./routes/orgs";
84import notificationRoutes from "./routes/notifications";
85import onboardingRoutes from "./routes/onboarding";
86import adminRoutes from "./routes/admin";
f764c07Claude87import adminDeploysRoutes from "./routes/admin-deploys";
88import adminDeploysPageRoutes from "./routes/admin-deploys-page";
9dd96b9Test User89import adminOpsRoutes from "./routes/admin-ops";
f2c00b4CC LABS App90import adminSelfHostRoutes from "./routes/admin-self-host";
826eccfTest User91import adminDiagnoseRoutes from "./routes/admin-diagnose";
509c376Claude92import adminIntegrationsRoutes from "./routes/admin-integrations";
79ed944Claude93import adminAdvancementRoutes from "./routes/admin-advancement";
0316dbbClaude94import advisoriesRoutes from "./routes/advisories";
95import aiChangelogRoutes from "./routes/ai-changelog";
96import aiExplainRoutes from "./routes/ai-explain";
97import aiTestsRoutes from "./routes/ai-tests";
98import askRoutes from "./routes/ask";
38d31d3Claude99import repoChatRoutes from "./routes/repo-chat";
0316dbbClaude100import billingRoutes from "./routes/billing";
8809b87Claude101import billingUsageRoutes from "./routes/billing-usage";
6778ad2Claude102import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude103import codeScanningRoutes from "./routes/code-scanning";
104import commitStatusesRoutes from "./routes/commit-statuses";
105import copilotRoutes from "./routes/copilot";
106import depUpdaterRoutes from "./routes/dep-updater";
107import depsRoutes from "./routes/deps";
108import discussionsRoutes from "./routes/discussions";
109import environmentsRoutes from "./routes/environments";
4bbacbeClaude110import previewsRoutes from "./routes/previews";
79ed944Claude111import docsTrackingRoutes from "./routes/docs-tracking";
0316dbbClaude112import followsRoutes from "./routes/follows";
113import gatesRoutes from "./routes/gates";
114import gistsRoutes from "./routes/gists";
115import graphqlRoutes from "./routes/graphql";
2c2163eClaude116import mcpRoutes from "./routes/mcp";
0316dbbClaude117import marketplaceRoutes from "./routes/marketplace";
5ca514aClaude118import marketplaceAgentsRoutes from "./routes/marketplace-agents";
0316dbbClaude119import mergeQueueRoutes from "./routes/merge-queue";
120import mirrorsRoutes from "./routes/mirrors";
121import orgInsightsRoutes from "./routes/org-insights";
122import packagesRoutes from "./routes/packages";
123import packagesApiRoutes from "./routes/packages-api";
124import pagesRoutes from "./routes/pages";
125import projectsRoutes from "./routes/projects";
126import protectedTagsRoutes from "./routes/protected-tags";
127import pwaRoutes from "./routes/pwa";
46d6165Claude128import installRoutes from "./routes/install";
cd4f63bTest User129import dxtRoutes from "./routes/dxt";
662ce86Claude130import connectClaudeRoutes from "./routes/connect-claude";
ebbb527Claude131import claudeDeployRoutes from "./routes/claude-deploy";
0316dbbClaude132import releasesRoutes from "./routes/releases";
133import requiredChecksRoutes from "./routes/required-checks";
134import rulesetsRoutes from "./routes/rulesets";
135import searchRoutes from "./routes/search";
136import semanticSearchRoutes from "./routes/semantic-search";
137import signingKeysRoutes from "./routes/signing-keys";
138import sponsorsRoutes from "./routes/sponsors";
139import ssoRoutes from "./routes/sso";
46d6165Claude140import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude141import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude142import symbolsRoutes from "./routes/symbols";
143import templatesRoutes from "./routes/templates";
144import trafficRoutes from "./routes/traffic";
145import wikisRoutes from "./routes/wikis";
146import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude147import workflowArtifactsRoutes from "./routes/workflow-artifacts";
148import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude149import sleepModeRoutes from "./routes/sleep-mode";
56801e1Claude150import standupRoutes from "./routes/standups";
52ad8b1Claude151import vsGithubRoutes from "./routes/vs-github";
45f3b73Claude152import voiceRoutes from "./routes/voice-to-pr";
cd4f63bTest User153import playgroundRoutes from "./routes/playground";
59b6fb2Claude154import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
155import { csrfToken, csrfProtect } from "./middleware/csrf";
79136bbClaude156
2316901Claude157import type { AuthEnv } from "./middleware/auth";
bf19c50Test User158import { softAuth } from "./middleware/auth";
2316901Claude159
160const app = new Hono<AuthEnv>();
79136bbClaude161
3ef4c9dClaude162// Request context (request ID, start time) runs before everything else
163app.use("*", requestContext);
05b973eClaude164// Middleware — compression first (wraps all responses)
165app.use("*", compress());
f1ffd50Claude166
167// ETag middleware — returns 304 Not Modified on unchanged responses.
168// Saves ~95% bandwidth on repeat visits. Skipped on git protocol +
169// SSE + the API surface where it would interfere with streaming.
170app.use("*", async (c, next) => {
171 const p = c.req.path;
172 if (
173 p.includes(".git/") ||
174 p.startsWith("/live-events") ||
175 p.startsWith("/api/events/deploy") ||
3c03977Claude176 p.startsWith("/admin/status") ||
177 // PR live co-editing SSE stream — never etag streaming responses.
178 /^\/api\/v2\/pulls\/[^/]+\/live(\/|$)/.test(p)
f1ffd50Claude179 ) {
180 return next();
181 }
182 return etag()(c, next);
183});
184
185// Cache-Control middleware — sets sensible defaults on public, anonymous
186// requests. Crontech (when wired as our edge layer) and downstream
187// browsers will honor these. Auth'd users get private,no-store
188// automatically — we never cache responses tied to a session.
189app.use("*", async (c, next) => {
190 await next();
191 // Don't overwrite explicit headers set by route handlers — BUT the
192 // ETag middleware unconditionally sets "private, no-cache, must-
193 // revalidate" so we have to treat that specific value as "no
194 // policy chosen yet" and apply ours. Any route that explicitly set
195 // a different cache-control wins.
196 const existing = c.res.headers.get("cache-control");
197 const etagDefault =
198 existing === "private, no-cache, must-revalidate" ||
199 existing === "no-cache";
200 if (existing && !etagDefault) return;
201 // Anything past auth: private + no-store (avoid leaking session
202 // content into shared caches). softAuth runs before this on the
203 // request, but the response side is what we're stamping.
204 const hasSession = c.req.header("cookie")?.includes("session=") ?? false;
205 const p = c.req.path;
206 // Always private for known-authed paths regardless of cookie.
207 if (
208 p.startsWith("/admin") ||
209 p.startsWith("/settings") ||
210 p.startsWith("/dashboard") ||
211 p.startsWith("/notifications") ||
212 p.startsWith("/connect/") ||
213 hasSession
214 ) {
215 c.res.headers.set("cache-control", "private, no-store");
216 return;
217 }
218 // Public marketing surfaces — short edge cache, longer browser cache,
219 // stale-while-revalidate so the user never waits on a stale fetch.
220 const isMarketing =
221 p === "/" ||
222 p === "/features" ||
223 p === "/pricing" ||
224 p === "/about" ||
225 p === "/vs-github" ||
226 p === "/explore" ||
227 p === "/help" ||
228 p === "/changelog" ||
229 p.startsWith("/legal/") ||
230 p === "/terms" ||
231 p === "/privacy" ||
232 p === "/acceptable-use" ||
233 p.startsWith("/docs/");
234 if (isMarketing) {
235 c.res.headers.set(
236 "cache-control",
237 "public, max-age=60, s-maxage=300, stale-while-revalidate=86400"
238 );
239 return;
240 }
241 // Public repo browse pages — cache aggressively. Edge invalidates
242 // on push via the post-receive hook (future Crontech surge purge).
243 if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") {
244 c.res.headers.set(
245 "cache-control",
246 "public, max-age=30, s-maxage=120, stale-while-revalidate=600"
247 );
248 return;
249 }
250 // Default: don't cache anything we haven't explicitly opted in.
251 c.res.headers.set("cache-control", "private, no-store");
252});
05b973eClaude253// Logger only on non-git routes to avoid overhead on clone/push
254app.use("*", async (c, next) => {
255 if (c.req.path.includes(".git/")) return next();
256 return logger()(c, next);
257});
79136bbClaude258app.use("/api/*", cors());
bf19c50Test User259// Global softAuth — populates c.get("user") for every downstream middleware
260// + route. This was previously per-route, which meant rate-limit middleware
261// (and anything else inspecting auth state) always saw a null user. Keep
262// individual routes free to add requireAuth on top for hard gating; this
263// just establishes the user object cheaply.
264app.use("*", softAuth);
290ea77Claude265
36cc17aClaude266// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude267// pre-redesign markup. JSON / static assets keep their own cache rules; only
268// text/html responses get the no-cache stamp. Without this, every push to
269// main left users staring at cached 80s-looking pages from before the design
270// landed.
36cc17aClaude271//
272// We deliberately use `private, no-cache, must-revalidate` rather than
273// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
274// which makes every Back/Forward press a cold server round-trip — that
275// contributed to the "every nav feels like a fresh login" UX complaint.
276// `no-cache` still revalidates on direct fetch but lets bfcache hold the
277// page in memory between navigations.
290ea77Claude278app.use("*", async (c, next) => {
279 await next();
280 const ct = c.res.headers.get("content-type") || "";
281 if (ct.startsWith("text/html")) {
36cc17aClaude282 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude283 }
284});
826eccfTest User285// Rate-limit API + auth endpoints.
286//
a41e675Test User287// `/api/*`: 1000/min per IP — generous so an admin clicking around the
288// operator console (or a CDN/proxy concentrating multiple users behind one
289// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
290// rate limits below, not this one.
291//
292// `authedMultiplier` is set but only fires when an upstream middleware has
293// already populated c.get("user") — most app.use() chains apply softAuth
294// per-route, so the multiplier is best-effort. Keep the anonymous base
295// high enough that humans never feel it.
296//
297// Skip-paths: dashboard plumbing endpoints that the layout polls on a
298// fixed cadence and that we don't want consuming any bucket:
299// /api/version — layout polls every 15s
826eccfTest User300// /api/notifications/count — nav bell unread-count fetcher
301// /pwa/vapid-public-key — fetched once per push-notification opt-in
302app.use(
303 "/api/*",
a41e675Test User304 rateLimit(1000, 60_000, "api", {
826eccfTest User305 authedMultiplier: 4,
306 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
307 })
308);
0316dbbClaude309app.use("/login", rateLimit(20, 60_000, "login"));
310app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude311// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
312app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User313// BLOCK Q2 — throttle magic-link sign-in for the same reason.
314app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude315
59b6fb2Claude316// CSRF protection — set token on all requests, validate on mutations
317app.use("*", csrfToken);
318app.use("*", csrfProtect);
319
45e31d0Claude320// Rate limit auth routes
321app.use("/login", authRateLimit);
322app.use("/register", authRateLimit);
323
59b6fb2Claude324// Rate limit git operations
325app.use("/:owner/:repo.git/*", gitRateLimit);
326
327// Rate limit search
328app.use("/:owner/:repo/search", searchRateLimit);
329app.use("/explore", searchRateLimit);
79136bbClaude330
331// Git Smart HTTP protocol routes (must be before web routes)
332app.route("/", gitRoutes);
333
45e31d0Claude334// REST API v1 (legacy)
79136bbClaude335app.route("/", apiRoutes);
336
52ad8b1Claude337// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
338// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
339// router's catch-shape, and BEFORE adminRoutes so the live /demo page
340// wins over the legacy /demo redirect in src/routes/admin.tsx.
341app.route("/", demoRoutes);
342
0316dbbClaude343// REST API v2 (basePath /api/v2)
344app.route("/", apiV2Routes);
345
e75eddcClaude346// Agent multiplayer v1 — /api/v2/agents/* (sessions, leases, usage).
347// Mounted alongside apiV2Routes (its own basePath, no path conflict).
348app.route("/", agentsRoutes);
349
ad6d4adClaude350// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
351app.route("/", hookRoutes);
21f8dbdClaude352app.route("/api/events", eventsRoutes);
ad6d4adClaude353
45e31d0Claude354// API documentation
355app.route("/", apiDocsRoutes);
4a80519Claude356app.route("/", buildAgentSpecRoutes);
a6ff0f2Claude357// PR command center — global PR dashboard with AI/GateTest/auto-merge signal
358app.route("/", pullsDashboardRoutes);
e9aa4d8Claude359// Issue command center — global issue dashboard with AI-triage + autopilot signal
360app.route("/", issuesDashboardRoutes);
361// Personal activity timeline — every event across the user's repos, with
362// AI-driven events surfaced separately (the Gluecron differentiator).
363app.route("/", activityRoutes);
364// Unified inbox — mentions + review requests + CI failures + AI events in one timeline
365app.route("/", inboxRoutes);
56801e1Claude366// AI standup feed — daily / weekly Claude-generated team brief
367app.route("/", standupRoutes);
79136bbClaude368
369// Auth routes (register, login, logout)
370app.route("/", authRoutes);
371
c63b860Claude372// BLOCK P1 — Password reset (forgot-password + reset-password)
373app.route("/", passwordResetRoutes);
374
375// BLOCK P2 — Email verification (verify-email + resend)
376app.route("/", emailVerificationRoutes);
377
cd4f63bTest User378// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
379app.route("/", magicLinkRoutes);
380
79136bbClaude381// Settings routes (profile, SSH keys)
382app.route("/", settingsRoutes);
383
7298a17Claude384// 2FA / TOTP settings (Block B4)
385app.route("/", settings2faRoutes);
386
e75eddcClaude387// Agent multiplayer — /settings/agents management UI
388app.route("/", settingsAgentsRoutes);
389
1d4ff60Claude390// Chat integrations — Slack / Discord / Teams (/settings/integrations
391// + /api/v2/integrations/{slack,discord}/*). See src/lib/chat-bot.ts.
392app.route("/", settingsIntegrationsRoutes);
393app.route("/", integrationsChatRoutes);
394
2df1f8cClaude395// WebAuthn / passkey routes (Block B5)
396app.route("/", passkeyRoutes);
397
058d752Claude398// OAuth 2.0 provider (Block B6)
399app.route("/", oauthRoutes);
400app.route("/", developerAppsRoutes);
401
6fc53bdClaude402// Theme toggle (dark/light cookie)
403app.route("/", themeRoutes);
404
405// Audit log UI
406app.route("/", auditRoutes);
407
408// Reactions API (issues, PRs, comments)
409app.route("/", reactionRoutes);
410
24cf2caClaude411// Saved replies (per-user canned comment templates)
412app.route("/", savedReplyRoutes);
413
414// Environments + deployment history UI
415app.route("/", deploymentRoutes);
416
6563f0aClaude417// Organizations + teams (Block B1)
418app.route("/", orgRoutes);
419
c81ab7aClaude420// API tokens
421app.route("/", tokenRoutes);
422
59b6fb2Claude423// Notifications
3ef4c9dClaude424app.route("/", notificationRoutes);
425
79136bbClaude426// Repo settings (description, visibility, delete)
427app.route("/", repoSettings);
428
23d1a81Claude429// Repo collaborators (add/list/remove)
430app.route("/", collaboratorRoutes);
431
04f6b7fClaude432// Team-based repo collaborators (invite a whole team)
433app.route("/", teamCollaboratorRoutes);
434
435// Collaborator invite accept flow (token-based)
436app.route("/", invitesRoutes);
437
438// Real-time SSE endpoint (topic-based live updates)
439app.route("/", liveEventsRoutes);
440
3c03977Claude441// PR live co-editing — presence + cursors + content sync via SSE.
442app.route("/", prLiveRoutes);
443
c81ab7aClaude444// Webhooks management
445app.route("/", webhookRoutes);
446
79136bbClaude447// Compare view (branch diffs)
448app.route("/", compareRoutes);
449
450// Issue tracker
451app.route("/", issueRoutes);
452
cb5a796Claude453// Comment moderation queue — owner-only `/:owner/:repo/comments/pending`
454// + per-row approve/reject/spam actions. Mounted before `pullRoutes` so
455// the `/:owner/:repo/comments/*` paths resolve before the broader PR
456// patterns kick in.
457app.route("/", commentModerationRoutes);
458
0074234Claude459// Pull requests
460app.route("/", pullRoutes);
79ed944Claude461// PR sandboxes — runnable per-PR environments. Migration 0067.
462app.route("/", prSandboxRoutes);
0074234Claude463
c81ab7aClaude464// Fork
465app.route("/", forkRoutes);
466
0074234Claude467// Web file editor
468app.route("/", editorRoutes);
469
43de941Claude470// Contributors
471app.route("/", contributorRoutes);
472
699e5c7Claude473// Health liveness + metrics endpoints
2c34075Claude474app.route("/", healthRoutes);
475
f295f78Dictation App476// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
477app.route("/api/platform-status", platformStatus);
478
52ad8b1Claude479// Block L4 — Public stats counters (powers landing-page social proof)
480app.route("/", publicStatsRoutes);
481
482// Block L3 — Live /demo page + /api/v2/demo/* endpoints
483app.route("/", demoRoutes);
484
2316be6Claude485// Public /status — human-readable platform health page
486app.route("/", statusRoutes);
487
b1be050CC LABS App488// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
489// Mounted near the public status route so the two surfaces are visible
490// side-by-side; routes are gated by isSiteAdmin internally.
491app.route("/", adminStatusRoutes);
492
80bed05Claude493// /help — quickstart + API cheatsheet
494app.route("/", helpRoutes);
495
5f2e749Claude496// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
497// so the new editorial pricing layout wins the route; the legacy marketing
498// pricing remains as a safety net but is shadowed at the router.
499app.route("/", pricingRoutes);
500
b0148e9Claude501// /pricing, /features, /about — marketing surface
502app.route("/", marketingRoutes);
503
5618f9aClaude504// SEO: robots.txt + sitemap.xml
505app.route("/", seoRoutes);
506
05cdb85Claude507// /api/version — live build SHA + uptime; client poller uses this to
508// surface 'New version available — reload' banners on deploy.
509app.route("/", versionRoutes);
510
699e5c7Claude511// Health dashboard (per-repo health page)
512app.route("/", healthDashboardRoutes);
513
9dd96b9Test User514// Block R1 — site-admin operations console. MUST be mounted BEFORE
515// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
516// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
517app.route("/", adminOpsRoutes);
f2c00b4CC LABS App518// BLOCK W — Self-host status + bootstrap dashboard.
519app.route("/", adminSelfHostRoutes);
826eccfTest User520// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
521app.route("/", adminDiagnoseRoutes);
9dd96b9Test User522
16b325cClaude523// Insights (time-travel, dependencies, rollback)
524app.route("/", insightRoutes);
525
f1ab587Claude526// Command center dashboard
527app.route("/", dashboardRoutes);
528
36b4cbdClaude529// Legal pages (terms, privacy, AUP)
530app.route("/", legalRoutes);
4b66018Claude531// Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}.
532// The main `legal.tsx` serves the short canonical paths (/terms, /privacy,
533// /acceptable-use); these are the formal versions that the legal pages
534// internally link to each other.
535app.route("/", legalTermsRoutes);
536app.route("/", legalPrivacyRoutes);
537app.route("/", legalAcceptableUseRoutes);
538app.route("/", legalDmcaRoutes);
36b4cbdClaude539
bdbd0deClaude540// GitHub import / migration
541app.route("/", importRoutes);
14c3cc8Claude542app.route("/", importBulkRoutes);
f390cfaCC LABS App543app.route("/", importSecretsRoutes);
14c3cc8Claude544app.route("/", migrationRoutes);
545
546// Spec-to-PR (experimental AI-generated draft PRs)
547app.route("/", specsRoutes);
23d0abfClaude548app.route("/", refactorRoutes);
bdbd0deClaude549
c81ab7aClaude550// Explore page
551app.route("/", exploreRoutes);
552
59b6fb2Claude553// Onboarding
554app.route("/", onboardingRoutes);
555
0316dbbClaude556// Admin + feature routes
557app.route("/", adminRoutes);
509c376Claude558app.route("/", adminIntegrationsRoutes);
79ed944Claude559app.route("/", adminAdvancementRoutes);
f764c07Claude560app.route("/", adminDeploysRoutes);
561app.route("/", adminDeploysPageRoutes);
9dd96b9Test User562// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude563app.route("/", advisoriesRoutes);
564app.route("/", aiChangelogRoutes);
565app.route("/", aiExplainRoutes);
566app.route("/", aiTestsRoutes);
567app.route("/", askRoutes);
38d31d3Claude568app.route("/", repoChatRoutes);
0316dbbClaude569app.route("/", billingRoutes);
8809b87Claude570app.route("/", billingUsageRoutes);
6778ad2Claude571app.route("/", stripeWebhookRoutes);
0316dbbClaude572app.route("/", codeScanningRoutes);
573app.route("/", commitStatusesRoutes);
574app.route("/", copilotRoutes);
575app.route("/", depUpdaterRoutes);
576app.route("/", depsRoutes);
577app.route("/", discussionsRoutes);
578app.route("/", environmentsRoutes);
4bbacbeClaude579app.route("/", previewsRoutes);
79ed944Claude580app.route("/", docsTrackingRoutes);
0316dbbClaude581app.route("/", followsRoutes);
582app.route("/", gatesRoutes);
583app.route("/", gistsRoutes);
584app.route("/", graphqlRoutes);
2c2163eClaude585app.route("/", mcpRoutes);
0316dbbClaude586app.route("/", marketplaceRoutes);
5ca514aClaude587app.route("/", marketplaceAgentsRoutes);
0316dbbClaude588app.route("/", mergeQueueRoutes);
589app.route("/", mirrorsRoutes);
590app.route("/", orgInsightsRoutes);
591app.route("/", packagesRoutes);
592app.route("/", packagesApiRoutes);
593app.route("/", pagesRoutes);
594app.route("/", projectsRoutes);
595app.route("/", protectedTagsRoutes);
596app.route("/", pwaRoutes);
46d6165Claude597app.route("/", installRoutes);
cd4f63bTest User598// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
599app.route("/", dxtRoutes);
662ce86Claude600// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
601// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
602app.route("/", connectClaudeRoutes);
ebbb527Claude603// Hosted Claude tool-use loops — paste loop, get endpoint, billing meter.
604// See src/routes/claude-deploy.tsx + src/lib/hosted-claude-loop.ts.
605app.route("/", claudeDeployRoutes);
0316dbbClaude606app.route("/", releasesRoutes);
607app.route("/", requiredChecksRoutes);
608app.route("/", rulesetsRoutes);
609app.route("/", searchRoutes);
610app.route("/", semanticSearchRoutes);
611app.route("/", signingKeysRoutes);
612app.route("/", sponsorsRoutes);
613app.route("/", ssoRoutes);
46d6165Claude614app.route("/", githubOauthRoutes);
582cdacClaude615app.route("/", googleOauthRoutes);
0316dbbClaude616app.route("/", symbolsRoutes);
617app.route("/", templatesRoutes);
618app.route("/", trafficRoutes);
619app.route("/", wikisRoutes);
620app.route("/", workflowsRoutes);
5ff9cc2Claude621app.route("/", workflowArtifactsRoutes);
622app.route("/", workflowSecretsRoutes);
46d6165Claude623app.route("/", sleepModeRoutes);
52ad8b1Claude624app.route("/", vsGithubRoutes);
0316dbbClaude625
45f3b73Claude626// Voice-to-PR — phone-first dictation → spec or issue
627app.route("/", voiceRoutes);
628
cd4f63bTest User629// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
630// before the web catch-all so the bare `/play` literal wins over the
631// `/:owner` user-profile route.
632app.route("/", playgroundRoutes);
633
79136bbClaude634// Web UI (catch-all, must be last)
635app.route("/", webRoutes);
636
c63b860Claude637// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
638// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude639app.notFound((c) => {
36cc17aClaude640 const user = c.get("user") ?? null;
79136bbClaude641 return c.html(
c63b860Claude642 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude643 404
644 );
645});
646
c63b860Claude647// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
648// view. Trace block only shown outside production.
79136bbClaude649app.onError((err, c) => {
80bed05Claude650 reportError(err, {
651 requestId: c.get("requestId"),
652 path: c.req.path,
653 method: c.req.method,
654 });
c63b860Claude655 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
656 // back to the context value set by request-context middleware.
657 const requestId =
658 c.req.header("x-request-id") ||
659 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude660 const user = c.get("user") ?? null;
c63b860Claude661 const trace =
662 process.env.NODE_ENV !== "production" && err && err.message
663 ? err.message
664 : undefined;
79136bbClaude665 return c.html(
c63b860Claude666 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude667 500
668 );
669});
670
671export default app;