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.tsxBlame651 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";
31import repoSettings from "./routes/repo-settings";
23d1a81Claude32import collaboratorRoutes from "./routes/collaborators";
04f6b7fClaude33import teamCollaboratorRoutes from "./routes/team-collaborators";
34import invitesRoutes from "./routes/invites";
35import liveEventsRoutes from "./routes/live-events";
3c03977Claude36import prLiveRoutes from "./routes/pr-live";
79136bbClaude37import compareRoutes from "./routes/compare";
0074234Claude38import pullRoutes from "./routes/pulls";
39import editorRoutes from "./routes/editor";
c81ab7aClaude40import forkRoutes from "./routes/fork";
41import webhookRoutes from "./routes/webhooks";
42import exploreRoutes from "./routes/explore";
43import tokenRoutes from "./routes/tokens";
43de941Claude44import contributorRoutes from "./routes/contributors";
699e5c7Claude45import healthRoutes from "./routes/health-probe";
46import healthDashboardRoutes from "./routes/health";
2316be6Claude47import statusRoutes from "./routes/status";
b1be050CC LABS App48import adminStatusRoutes from "./routes/admin-status";
80bed05Claude49import helpRoutes from "./routes/help";
b0148e9Claude50import marketingRoutes from "./routes/marketing";
5f2e749Claude51import pricingRoutes from "./routes/pricing";
5618f9aClaude52import seoRoutes from "./routes/seo";
05cdb85Claude53import versionRoutes from "./routes/version";
f295f78Dictation App54import { platformStatus } from "./routes/platform-status";
52ad8b1Claude55import publicStatsRoutes from "./routes/public-stats";
56import demoRoutes from "./routes/demo";
16b325cClaude57import insightRoutes from "./routes/insights";
f1ab587Claude58import dashboardRoutes from "./routes/dashboard";
36b4cbdClaude59import legalRoutes from "./routes/legal";
4b66018Claude60import legalDmcaRoutes from "./routes/legal/dmca";
61import legalTermsRoutes from "./routes/legal/terms";
62import legalPrivacyRoutes from "./routes/legal/privacy";
63import legalAcceptableUseRoutes from "./routes/legal/acceptable-use";
bdbd0deClaude64import importRoutes from "./routes/import";
14c3cc8Claude65import importBulkRoutes from "./routes/import-bulk";
f390cfaCC LABS App66import importSecretsRoutes from "./routes/import-secrets";
14c3cc8Claude67import migrationRoutes from "./routes/migrations";
68import specsRoutes from "./routes/specs";
23d0abfClaude69import refactorRoutes from "./routes/refactors";
79136bbClaude70import webRoutes from "./routes/web";
0316dbbClaude71import hookRoutes from "./routes/hooks";
72import eventsRoutes from "./routes/events";
73import passkeyRoutes from "./routes/passkeys";
74import oauthRoutes from "./routes/oauth";
75import developerAppsRoutes from "./routes/developer-apps";
76import themeRoutes from "./routes/theme";
77import auditRoutes from "./routes/audit";
78import reactionRoutes from "./routes/reactions";
79import savedReplyRoutes from "./routes/saved-replies";
80import deploymentRoutes from "./routes/deployments";
81import orgRoutes from "./routes/orgs";
82import notificationRoutes from "./routes/notifications";
83import onboardingRoutes from "./routes/onboarding";
84import adminRoutes from "./routes/admin";
f764c07Claude85import adminDeploysRoutes from "./routes/admin-deploys";
86import adminDeploysPageRoutes from "./routes/admin-deploys-page";
9dd96b9Test User87import adminOpsRoutes from "./routes/admin-ops";
f2c00b4CC LABS App88import adminSelfHostRoutes from "./routes/admin-self-host";
826eccfTest User89import adminDiagnoseRoutes from "./routes/admin-diagnose";
509c376Claude90import adminIntegrationsRoutes from "./routes/admin-integrations";
0316dbbClaude91import advisoriesRoutes from "./routes/advisories";
92import aiChangelogRoutes from "./routes/ai-changelog";
93import aiExplainRoutes from "./routes/ai-explain";
94import aiTestsRoutes from "./routes/ai-tests";
95import askRoutes from "./routes/ask";
38d31d3Claude96import repoChatRoutes from "./routes/repo-chat";
0316dbbClaude97import billingRoutes from "./routes/billing";
8809b87Claude98import billingUsageRoutes from "./routes/billing-usage";
6778ad2Claude99import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude100import codeScanningRoutes from "./routes/code-scanning";
101import commitStatusesRoutes from "./routes/commit-statuses";
102import copilotRoutes from "./routes/copilot";
103import depUpdaterRoutes from "./routes/dep-updater";
104import depsRoutes from "./routes/deps";
105import discussionsRoutes from "./routes/discussions";
106import environmentsRoutes from "./routes/environments";
4bbacbeClaude107import previewsRoutes from "./routes/previews";
0316dbbClaude108import followsRoutes from "./routes/follows";
109import gatesRoutes from "./routes/gates";
110import gistsRoutes from "./routes/gists";
111import graphqlRoutes from "./routes/graphql";
2c2163eClaude112import mcpRoutes from "./routes/mcp";
0316dbbClaude113import marketplaceRoutes from "./routes/marketplace";
114import mergeQueueRoutes from "./routes/merge-queue";
115import mirrorsRoutes from "./routes/mirrors";
116import orgInsightsRoutes from "./routes/org-insights";
117import packagesRoutes from "./routes/packages";
118import packagesApiRoutes from "./routes/packages-api";
119import pagesRoutes from "./routes/pages";
120import projectsRoutes from "./routes/projects";
121import protectedTagsRoutes from "./routes/protected-tags";
122import pwaRoutes from "./routes/pwa";
46d6165Claude123import installRoutes from "./routes/install";
cd4f63bTest User124import dxtRoutes from "./routes/dxt";
662ce86Claude125import connectClaudeRoutes from "./routes/connect-claude";
0316dbbClaude126import releasesRoutes from "./routes/releases";
127import requiredChecksRoutes from "./routes/required-checks";
128import rulesetsRoutes from "./routes/rulesets";
129import searchRoutes from "./routes/search";
130import semanticSearchRoutes from "./routes/semantic-search";
131import signingKeysRoutes from "./routes/signing-keys";
132import sponsorsRoutes from "./routes/sponsors";
133import ssoRoutes from "./routes/sso";
46d6165Claude134import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude135import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude136import symbolsRoutes from "./routes/symbols";
137import templatesRoutes from "./routes/templates";
138import trafficRoutes from "./routes/traffic";
139import wikisRoutes from "./routes/wikis";
140import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude141import workflowArtifactsRoutes from "./routes/workflow-artifacts";
142import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude143import sleepModeRoutes from "./routes/sleep-mode";
56801e1Claude144import standupRoutes from "./routes/standups";
52ad8b1Claude145import vsGithubRoutes from "./routes/vs-github";
45f3b73Claude146import voiceRoutes from "./routes/voice-to-pr";
cd4f63bTest User147import playgroundRoutes from "./routes/playground";
59b6fb2Claude148import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
149import { csrfToken, csrfProtect } from "./middleware/csrf";
79136bbClaude150
2316901Claude151import type { AuthEnv } from "./middleware/auth";
bf19c50Test User152import { softAuth } from "./middleware/auth";
2316901Claude153
154const app = new Hono<AuthEnv>();
79136bbClaude155
3ef4c9dClaude156// Request context (request ID, start time) runs before everything else
157app.use("*", requestContext);
05b973eClaude158// Middleware — compression first (wraps all responses)
159app.use("*", compress());
f1ffd50Claude160
161// ETag middleware — returns 304 Not Modified on unchanged responses.
162// Saves ~95% bandwidth on repeat visits. Skipped on git protocol +
163// SSE + the API surface where it would interfere with streaming.
164app.use("*", async (c, next) => {
165 const p = c.req.path;
166 if (
167 p.includes(".git/") ||
168 p.startsWith("/live-events") ||
169 p.startsWith("/api/events/deploy") ||
3c03977Claude170 p.startsWith("/admin/status") ||
171 // PR live co-editing SSE stream — never etag streaming responses.
172 /^\/api\/v2\/pulls\/[^/]+\/live(\/|$)/.test(p)
f1ffd50Claude173 ) {
174 return next();
175 }
176 return etag()(c, next);
177});
178
179// Cache-Control middleware — sets sensible defaults on public, anonymous
180// requests. Crontech (when wired as our edge layer) and downstream
181// browsers will honor these. Auth'd users get private,no-store
182// automatically — we never cache responses tied to a session.
183app.use("*", async (c, next) => {
184 await next();
185 // Don't overwrite explicit headers set by route handlers — BUT the
186 // ETag middleware unconditionally sets "private, no-cache, must-
187 // revalidate" so we have to treat that specific value as "no
188 // policy chosen yet" and apply ours. Any route that explicitly set
189 // a different cache-control wins.
190 const existing = c.res.headers.get("cache-control");
191 const etagDefault =
192 existing === "private, no-cache, must-revalidate" ||
193 existing === "no-cache";
194 if (existing && !etagDefault) return;
195 // Anything past auth: private + no-store (avoid leaking session
196 // content into shared caches). softAuth runs before this on the
197 // request, but the response side is what we're stamping.
198 const hasSession = c.req.header("cookie")?.includes("session=") ?? false;
199 const p = c.req.path;
200 // Always private for known-authed paths regardless of cookie.
201 if (
202 p.startsWith("/admin") ||
203 p.startsWith("/settings") ||
204 p.startsWith("/dashboard") ||
205 p.startsWith("/notifications") ||
206 p.startsWith("/connect/") ||
207 hasSession
208 ) {
209 c.res.headers.set("cache-control", "private, no-store");
210 return;
211 }
212 // Public marketing surfaces — short edge cache, longer browser cache,
213 // stale-while-revalidate so the user never waits on a stale fetch.
214 const isMarketing =
215 p === "/" ||
216 p === "/features" ||
217 p === "/pricing" ||
218 p === "/about" ||
219 p === "/vs-github" ||
220 p === "/explore" ||
221 p === "/help" ||
222 p === "/changelog" ||
223 p.startsWith("/legal/") ||
224 p === "/terms" ||
225 p === "/privacy" ||
226 p === "/acceptable-use" ||
227 p.startsWith("/docs/");
228 if (isMarketing) {
229 c.res.headers.set(
230 "cache-control",
231 "public, max-age=60, s-maxage=300, stale-while-revalidate=86400"
232 );
233 return;
234 }
235 // Public repo browse pages — cache aggressively. Edge invalidates
236 // on push via the post-receive hook (future Crontech surge purge).
237 if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") {
238 c.res.headers.set(
239 "cache-control",
240 "public, max-age=30, s-maxage=120, stale-while-revalidate=600"
241 );
242 return;
243 }
244 // Default: don't cache anything we haven't explicitly opted in.
245 c.res.headers.set("cache-control", "private, no-store");
246});
05b973eClaude247// Logger only on non-git routes to avoid overhead on clone/push
248app.use("*", async (c, next) => {
249 if (c.req.path.includes(".git/")) return next();
250 return logger()(c, next);
251});
79136bbClaude252app.use("/api/*", cors());
bf19c50Test User253// Global softAuth — populates c.get("user") for every downstream middleware
254// + route. This was previously per-route, which meant rate-limit middleware
255// (and anything else inspecting auth state) always saw a null user. Keep
256// individual routes free to add requireAuth on top for hard gating; this
257// just establishes the user object cheaply.
258app.use("*", softAuth);
290ea77Claude259
36cc17aClaude260// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude261// pre-redesign markup. JSON / static assets keep their own cache rules; only
262// text/html responses get the no-cache stamp. Without this, every push to
263// main left users staring at cached 80s-looking pages from before the design
264// landed.
36cc17aClaude265//
266// We deliberately use `private, no-cache, must-revalidate` rather than
267// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
268// which makes every Back/Forward press a cold server round-trip — that
269// contributed to the "every nav feels like a fresh login" UX complaint.
270// `no-cache` still revalidates on direct fetch but lets bfcache hold the
271// page in memory between navigations.
290ea77Claude272app.use("*", async (c, next) => {
273 await next();
274 const ct = c.res.headers.get("content-type") || "";
275 if (ct.startsWith("text/html")) {
36cc17aClaude276 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude277 }
278});
826eccfTest User279// Rate-limit API + auth endpoints.
280//
a41e675Test User281// `/api/*`: 1000/min per IP — generous so an admin clicking around the
282// operator console (or a CDN/proxy concentrating multiple users behind one
283// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
284// rate limits below, not this one.
285//
286// `authedMultiplier` is set but only fires when an upstream middleware has
287// already populated c.get("user") — most app.use() chains apply softAuth
288// per-route, so the multiplier is best-effort. Keep the anonymous base
289// high enough that humans never feel it.
290//
291// Skip-paths: dashboard plumbing endpoints that the layout polls on a
292// fixed cadence and that we don't want consuming any bucket:
293// /api/version — layout polls every 15s
826eccfTest User294// /api/notifications/count — nav bell unread-count fetcher
295// /pwa/vapid-public-key — fetched once per push-notification opt-in
296app.use(
297 "/api/*",
a41e675Test User298 rateLimit(1000, 60_000, "api", {
826eccfTest User299 authedMultiplier: 4,
300 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
301 })
302);
0316dbbClaude303app.use("/login", rateLimit(20, 60_000, "login"));
304app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude305// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
306app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User307// BLOCK Q2 — throttle magic-link sign-in for the same reason.
308app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude309
59b6fb2Claude310// CSRF protection — set token on all requests, validate on mutations
311app.use("*", csrfToken);
312app.use("*", csrfProtect);
313
45e31d0Claude314// Rate limit auth routes
315app.use("/login", authRateLimit);
316app.use("/register", authRateLimit);
317
59b6fb2Claude318// Rate limit git operations
319app.use("/:owner/:repo.git/*", gitRateLimit);
320
321// Rate limit search
322app.use("/:owner/:repo/search", searchRateLimit);
323app.use("/explore", searchRateLimit);
79136bbClaude324
325// Git Smart HTTP protocol routes (must be before web routes)
326app.route("/", gitRoutes);
327
45e31d0Claude328// REST API v1 (legacy)
79136bbClaude329app.route("/", apiRoutes);
330
52ad8b1Claude331// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
332// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
333// router's catch-shape, and BEFORE adminRoutes so the live /demo page
334// wins over the legacy /demo redirect in src/routes/admin.tsx.
335app.route("/", demoRoutes);
336
0316dbbClaude337// REST API v2 (basePath /api/v2)
338app.route("/", apiV2Routes);
339
e75eddcClaude340// Agent multiplayer v1 — /api/v2/agents/* (sessions, leases, usage).
341// Mounted alongside apiV2Routes (its own basePath, no path conflict).
342app.route("/", agentsRoutes);
343
ad6d4adClaude344// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
345app.route("/", hookRoutes);
21f8dbdClaude346app.route("/api/events", eventsRoutes);
ad6d4adClaude347
45e31d0Claude348// API documentation
349app.route("/", apiDocsRoutes);
4a80519Claude350app.route("/", buildAgentSpecRoutes);
a6ff0f2Claude351// PR command center — global PR dashboard with AI/GateTest/auto-merge signal
352app.route("/", pullsDashboardRoutes);
e9aa4d8Claude353// Issue command center — global issue dashboard with AI-triage + autopilot signal
354app.route("/", issuesDashboardRoutes);
355// Personal activity timeline — every event across the user's repos, with
356// AI-driven events surfaced separately (the Gluecron differentiator).
357app.route("/", activityRoutes);
358// Unified inbox — mentions + review requests + CI failures + AI events in one timeline
359app.route("/", inboxRoutes);
56801e1Claude360// AI standup feed — daily / weekly Claude-generated team brief
361app.route("/", standupRoutes);
79136bbClaude362
363// Auth routes (register, login, logout)
364app.route("/", authRoutes);
365
c63b860Claude366// BLOCK P1 — Password reset (forgot-password + reset-password)
367app.route("/", passwordResetRoutes);
368
369// BLOCK P2 — Email verification (verify-email + resend)
370app.route("/", emailVerificationRoutes);
371
cd4f63bTest User372// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
373app.route("/", magicLinkRoutes);
374
79136bbClaude375// Settings routes (profile, SSH keys)
376app.route("/", settingsRoutes);
377
7298a17Claude378// 2FA / TOTP settings (Block B4)
379app.route("/", settings2faRoutes);
380
e75eddcClaude381// Agent multiplayer — /settings/agents management UI
382app.route("/", settingsAgentsRoutes);
383
1d4ff60Claude384// Chat integrations — Slack / Discord / Teams (/settings/integrations
385// + /api/v2/integrations/{slack,discord}/*). See src/lib/chat-bot.ts.
386app.route("/", settingsIntegrationsRoutes);
387app.route("/", integrationsChatRoutes);
388
2df1f8cClaude389// WebAuthn / passkey routes (Block B5)
390app.route("/", passkeyRoutes);
391
058d752Claude392// OAuth 2.0 provider (Block B6)
393app.route("/", oauthRoutes);
394app.route("/", developerAppsRoutes);
395
6fc53bdClaude396// Theme toggle (dark/light cookie)
397app.route("/", themeRoutes);
398
399// Audit log UI
400app.route("/", auditRoutes);
401
402// Reactions API (issues, PRs, comments)
403app.route("/", reactionRoutes);
404
24cf2caClaude405// Saved replies (per-user canned comment templates)
406app.route("/", savedReplyRoutes);
407
408// Environments + deployment history UI
409app.route("/", deploymentRoutes);
410
6563f0aClaude411// Organizations + teams (Block B1)
412app.route("/", orgRoutes);
413
c81ab7aClaude414// API tokens
415app.route("/", tokenRoutes);
416
59b6fb2Claude417// Notifications
3ef4c9dClaude418app.route("/", notificationRoutes);
419
79136bbClaude420// Repo settings (description, visibility, delete)
421app.route("/", repoSettings);
422
23d1a81Claude423// Repo collaborators (add/list/remove)
424app.route("/", collaboratorRoutes);
425
04f6b7fClaude426// Team-based repo collaborators (invite a whole team)
427app.route("/", teamCollaboratorRoutes);
428
429// Collaborator invite accept flow (token-based)
430app.route("/", invitesRoutes);
431
432// Real-time SSE endpoint (topic-based live updates)
433app.route("/", liveEventsRoutes);
434
3c03977Claude435// PR live co-editing — presence + cursors + content sync via SSE.
436app.route("/", prLiveRoutes);
437
c81ab7aClaude438// Webhooks management
439app.route("/", webhookRoutes);
440
79136bbClaude441// Compare view (branch diffs)
442app.route("/", compareRoutes);
443
444// Issue tracker
445app.route("/", issueRoutes);
446
0074234Claude447// Pull requests
448app.route("/", pullRoutes);
449
c81ab7aClaude450// Fork
451app.route("/", forkRoutes);
452
0074234Claude453// Web file editor
454app.route("/", editorRoutes);
455
43de941Claude456// Contributors
457app.route("/", contributorRoutes);
458
699e5c7Claude459// Health liveness + metrics endpoints
2c34075Claude460app.route("/", healthRoutes);
461
f295f78Dictation App462// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
463app.route("/api/platform-status", platformStatus);
464
52ad8b1Claude465// Block L4 — Public stats counters (powers landing-page social proof)
466app.route("/", publicStatsRoutes);
467
468// Block L3 — Live /demo page + /api/v2/demo/* endpoints
469app.route("/", demoRoutes);
470
2316be6Claude471// Public /status — human-readable platform health page
472app.route("/", statusRoutes);
473
b1be050CC LABS App474// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
475// Mounted near the public status route so the two surfaces are visible
476// side-by-side; routes are gated by isSiteAdmin internally.
477app.route("/", adminStatusRoutes);
478
80bed05Claude479// /help — quickstart + API cheatsheet
480app.route("/", helpRoutes);
481
5f2e749Claude482// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
483// so the new editorial pricing layout wins the route; the legacy marketing
484// pricing remains as a safety net but is shadowed at the router.
485app.route("/", pricingRoutes);
486
b0148e9Claude487// /pricing, /features, /about — marketing surface
488app.route("/", marketingRoutes);
489
5618f9aClaude490// SEO: robots.txt + sitemap.xml
491app.route("/", seoRoutes);
492
05cdb85Claude493// /api/version — live build SHA + uptime; client poller uses this to
494// surface 'New version available — reload' banners on deploy.
495app.route("/", versionRoutes);
496
699e5c7Claude497// Health dashboard (per-repo health page)
498app.route("/", healthDashboardRoutes);
499
9dd96b9Test User500// Block R1 — site-admin operations console. MUST be mounted BEFORE
501// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
502// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
503app.route("/", adminOpsRoutes);
f2c00b4CC LABS App504// BLOCK W — Self-host status + bootstrap dashboard.
505app.route("/", adminSelfHostRoutes);
826eccfTest User506// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
507app.route("/", adminDiagnoseRoutes);
9dd96b9Test User508
16b325cClaude509// Insights (time-travel, dependencies, rollback)
510app.route("/", insightRoutes);
511
f1ab587Claude512// Command center dashboard
513app.route("/", dashboardRoutes);
514
36b4cbdClaude515// Legal pages (terms, privacy, AUP)
516app.route("/", legalRoutes);
4b66018Claude517// Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}.
518// The main `legal.tsx` serves the short canonical paths (/terms, /privacy,
519// /acceptable-use); these are the formal versions that the legal pages
520// internally link to each other.
521app.route("/", legalTermsRoutes);
522app.route("/", legalPrivacyRoutes);
523app.route("/", legalAcceptableUseRoutes);
524app.route("/", legalDmcaRoutes);
36b4cbdClaude525
bdbd0deClaude526// GitHub import / migration
527app.route("/", importRoutes);
14c3cc8Claude528app.route("/", importBulkRoutes);
f390cfaCC LABS App529app.route("/", importSecretsRoutes);
14c3cc8Claude530app.route("/", migrationRoutes);
531
532// Spec-to-PR (experimental AI-generated draft PRs)
533app.route("/", specsRoutes);
23d0abfClaude534app.route("/", refactorRoutes);
bdbd0deClaude535
c81ab7aClaude536// Explore page
537app.route("/", exploreRoutes);
538
59b6fb2Claude539// Onboarding
540app.route("/", onboardingRoutes);
541
0316dbbClaude542// Admin + feature routes
543app.route("/", adminRoutes);
509c376Claude544app.route("/", adminIntegrationsRoutes);
f764c07Claude545app.route("/", adminDeploysRoutes);
546app.route("/", adminDeploysPageRoutes);
9dd96b9Test User547// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude548app.route("/", advisoriesRoutes);
549app.route("/", aiChangelogRoutes);
550app.route("/", aiExplainRoutes);
551app.route("/", aiTestsRoutes);
552app.route("/", askRoutes);
38d31d3Claude553app.route("/", repoChatRoutes);
0316dbbClaude554app.route("/", billingRoutes);
8809b87Claude555app.route("/", billingUsageRoutes);
6778ad2Claude556app.route("/", stripeWebhookRoutes);
0316dbbClaude557app.route("/", codeScanningRoutes);
558app.route("/", commitStatusesRoutes);
559app.route("/", copilotRoutes);
560app.route("/", depUpdaterRoutes);
561app.route("/", depsRoutes);
562app.route("/", discussionsRoutes);
563app.route("/", environmentsRoutes);
4bbacbeClaude564app.route("/", previewsRoutes);
0316dbbClaude565app.route("/", followsRoutes);
566app.route("/", gatesRoutes);
567app.route("/", gistsRoutes);
568app.route("/", graphqlRoutes);
2c2163eClaude569app.route("/", mcpRoutes);
0316dbbClaude570app.route("/", marketplaceRoutes);
571app.route("/", mergeQueueRoutes);
572app.route("/", mirrorsRoutes);
573app.route("/", orgInsightsRoutes);
574app.route("/", packagesRoutes);
575app.route("/", packagesApiRoutes);
576app.route("/", pagesRoutes);
577app.route("/", projectsRoutes);
578app.route("/", protectedTagsRoutes);
579app.route("/", pwaRoutes);
46d6165Claude580app.route("/", installRoutes);
cd4f63bTest User581// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
582app.route("/", dxtRoutes);
662ce86Claude583// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
584// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
585app.route("/", connectClaudeRoutes);
0316dbbClaude586app.route("/", releasesRoutes);
587app.route("/", requiredChecksRoutes);
588app.route("/", rulesetsRoutes);
589app.route("/", searchRoutes);
590app.route("/", semanticSearchRoutes);
591app.route("/", signingKeysRoutes);
592app.route("/", sponsorsRoutes);
593app.route("/", ssoRoutes);
46d6165Claude594app.route("/", githubOauthRoutes);
582cdacClaude595app.route("/", googleOauthRoutes);
0316dbbClaude596app.route("/", symbolsRoutes);
597app.route("/", templatesRoutes);
598app.route("/", trafficRoutes);
599app.route("/", wikisRoutes);
600app.route("/", workflowsRoutes);
5ff9cc2Claude601app.route("/", workflowArtifactsRoutes);
602app.route("/", workflowSecretsRoutes);
46d6165Claude603app.route("/", sleepModeRoutes);
52ad8b1Claude604app.route("/", vsGithubRoutes);
0316dbbClaude605
45f3b73Claude606// Voice-to-PR — phone-first dictation → spec or issue
607app.route("/", voiceRoutes);
608
cd4f63bTest User609// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
610// before the web catch-all so the bare `/play` literal wins over the
611// `/:owner` user-profile route.
612app.route("/", playgroundRoutes);
613
79136bbClaude614// Web UI (catch-all, must be last)
615app.route("/", webRoutes);
616
c63b860Claude617// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
618// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude619app.notFound((c) => {
36cc17aClaude620 const user = c.get("user") ?? null;
79136bbClaude621 return c.html(
c63b860Claude622 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude623 404
624 );
625});
626
c63b860Claude627// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
628// view. Trace block only shown outside production.
79136bbClaude629app.onError((err, c) => {
80bed05Claude630 reportError(err, {
631 requestId: c.get("requestId"),
632 path: c.req.path,
633 method: c.req.method,
634 });
c63b860Claude635 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
636 // back to the context value set by request-context middleware.
637 const requestId =
638 c.req.header("x-request-id") ||
639 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude640 const user = c.get("user") ?? null;
c63b860Claude641 const trace =
642 process.env.NODE_ENV !== "production" && err && err.message
643 ? err.message
644 : undefined;
79136bbClaude645 return c.html(
c63b860Claude646 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude647 500
648 );
649});
650
651export default app;