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.tsxBlame658 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";
79ed944Claude39import prSandboxRoutes from "./routes/pr-sandbox";
0074234Claude40import editorRoutes from "./routes/editor";
c81ab7aClaude41import forkRoutes from "./routes/fork";
42import webhookRoutes from "./routes/webhooks";
43import exploreRoutes from "./routes/explore";
44import tokenRoutes from "./routes/tokens";
43de941Claude45import contributorRoutes from "./routes/contributors";
699e5c7Claude46import healthRoutes from "./routes/health-probe";
47import healthDashboardRoutes from "./routes/health";
2316be6Claude48import statusRoutes from "./routes/status";
b1be050CC LABS App49import adminStatusRoutes from "./routes/admin-status";
80bed05Claude50import helpRoutes from "./routes/help";
b0148e9Claude51import marketingRoutes from "./routes/marketing";
5f2e749Claude52import pricingRoutes from "./routes/pricing";
5618f9aClaude53import seoRoutes from "./routes/seo";
05cdb85Claude54import versionRoutes from "./routes/version";
f295f78Dictation App55import { platformStatus } from "./routes/platform-status";
52ad8b1Claude56import publicStatsRoutes from "./routes/public-stats";
57import demoRoutes from "./routes/demo";
16b325cClaude58import insightRoutes from "./routes/insights";
f1ab587Claude59import dashboardRoutes from "./routes/dashboard";
36b4cbdClaude60import legalRoutes from "./routes/legal";
4b66018Claude61import legalDmcaRoutes from "./routes/legal/dmca";
62import legalTermsRoutes from "./routes/legal/terms";
63import legalPrivacyRoutes from "./routes/legal/privacy";
64import legalAcceptableUseRoutes from "./routes/legal/acceptable-use";
bdbd0deClaude65import importRoutes from "./routes/import";
14c3cc8Claude66import importBulkRoutes from "./routes/import-bulk";
f390cfaCC LABS App67import importSecretsRoutes from "./routes/import-secrets";
14c3cc8Claude68import migrationRoutes from "./routes/migrations";
69import specsRoutes from "./routes/specs";
23d0abfClaude70import refactorRoutes from "./routes/refactors";
79136bbClaude71import webRoutes from "./routes/web";
0316dbbClaude72import hookRoutes from "./routes/hooks";
73import eventsRoutes from "./routes/events";
74import passkeyRoutes from "./routes/passkeys";
75import oauthRoutes from "./routes/oauth";
76import developerAppsRoutes from "./routes/developer-apps";
77import themeRoutes from "./routes/theme";
78import auditRoutes from "./routes/audit";
79import reactionRoutes from "./routes/reactions";
80import savedReplyRoutes from "./routes/saved-replies";
81import deploymentRoutes from "./routes/deployments";
82import orgRoutes from "./routes/orgs";
83import notificationRoutes from "./routes/notifications";
84import onboardingRoutes from "./routes/onboarding";
85import adminRoutes from "./routes/admin";
f764c07Claude86import adminDeploysRoutes from "./routes/admin-deploys";
87import adminDeploysPageRoutes from "./routes/admin-deploys-page";
9dd96b9Test User88import adminOpsRoutes from "./routes/admin-ops";
f2c00b4CC LABS App89import adminSelfHostRoutes from "./routes/admin-self-host";
826eccfTest User90import adminDiagnoseRoutes from "./routes/admin-diagnose";
509c376Claude91import adminIntegrationsRoutes from "./routes/admin-integrations";
79ed944Claude92import adminAdvancementRoutes from "./routes/admin-advancement";
0316dbbClaude93import advisoriesRoutes from "./routes/advisories";
94import aiChangelogRoutes from "./routes/ai-changelog";
95import aiExplainRoutes from "./routes/ai-explain";
96import aiTestsRoutes from "./routes/ai-tests";
97import askRoutes from "./routes/ask";
38d31d3Claude98import repoChatRoutes from "./routes/repo-chat";
0316dbbClaude99import billingRoutes from "./routes/billing";
8809b87Claude100import billingUsageRoutes from "./routes/billing-usage";
6778ad2Claude101import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude102import codeScanningRoutes from "./routes/code-scanning";
103import commitStatusesRoutes from "./routes/commit-statuses";
104import copilotRoutes from "./routes/copilot";
105import depUpdaterRoutes from "./routes/dep-updater";
106import depsRoutes from "./routes/deps";
107import discussionsRoutes from "./routes/discussions";
108import environmentsRoutes from "./routes/environments";
4bbacbeClaude109import previewsRoutes from "./routes/previews";
79ed944Claude110import docsTrackingRoutes from "./routes/docs-tracking";
0316dbbClaude111import followsRoutes from "./routes/follows";
112import gatesRoutes from "./routes/gates";
113import gistsRoutes from "./routes/gists";
114import graphqlRoutes from "./routes/graphql";
2c2163eClaude115import mcpRoutes from "./routes/mcp";
0316dbbClaude116import marketplaceRoutes from "./routes/marketplace";
117import mergeQueueRoutes from "./routes/merge-queue";
118import mirrorsRoutes from "./routes/mirrors";
119import orgInsightsRoutes from "./routes/org-insights";
120import packagesRoutes from "./routes/packages";
121import packagesApiRoutes from "./routes/packages-api";
122import pagesRoutes from "./routes/pages";
123import projectsRoutes from "./routes/projects";
124import protectedTagsRoutes from "./routes/protected-tags";
125import pwaRoutes from "./routes/pwa";
46d6165Claude126import installRoutes from "./routes/install";
cd4f63bTest User127import dxtRoutes from "./routes/dxt";
662ce86Claude128import connectClaudeRoutes from "./routes/connect-claude";
0316dbbClaude129import releasesRoutes from "./routes/releases";
130import requiredChecksRoutes from "./routes/required-checks";
131import rulesetsRoutes from "./routes/rulesets";
132import searchRoutes from "./routes/search";
133import semanticSearchRoutes from "./routes/semantic-search";
134import signingKeysRoutes from "./routes/signing-keys";
135import sponsorsRoutes from "./routes/sponsors";
136import ssoRoutes from "./routes/sso";
46d6165Claude137import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude138import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude139import symbolsRoutes from "./routes/symbols";
140import templatesRoutes from "./routes/templates";
141import trafficRoutes from "./routes/traffic";
142import wikisRoutes from "./routes/wikis";
143import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude144import workflowArtifactsRoutes from "./routes/workflow-artifacts";
145import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude146import sleepModeRoutes from "./routes/sleep-mode";
56801e1Claude147import standupRoutes from "./routes/standups";
52ad8b1Claude148import vsGithubRoutes from "./routes/vs-github";
45f3b73Claude149import voiceRoutes from "./routes/voice-to-pr";
cd4f63bTest User150import playgroundRoutes from "./routes/playground";
59b6fb2Claude151import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
152import { csrfToken, csrfProtect } from "./middleware/csrf";
79136bbClaude153
2316901Claude154import type { AuthEnv } from "./middleware/auth";
bf19c50Test User155import { softAuth } from "./middleware/auth";
2316901Claude156
157const app = new Hono<AuthEnv>();
79136bbClaude158
3ef4c9dClaude159// Request context (request ID, start time) runs before everything else
160app.use("*", requestContext);
05b973eClaude161// Middleware — compression first (wraps all responses)
162app.use("*", compress());
f1ffd50Claude163
164// ETag middleware — returns 304 Not Modified on unchanged responses.
165// Saves ~95% bandwidth on repeat visits. Skipped on git protocol +
166// SSE + the API surface where it would interfere with streaming.
167app.use("*", async (c, next) => {
168 const p = c.req.path;
169 if (
170 p.includes(".git/") ||
171 p.startsWith("/live-events") ||
172 p.startsWith("/api/events/deploy") ||
3c03977Claude173 p.startsWith("/admin/status") ||
174 // PR live co-editing SSE stream — never etag streaming responses.
175 /^\/api\/v2\/pulls\/[^/]+\/live(\/|$)/.test(p)
f1ffd50Claude176 ) {
177 return next();
178 }
179 return etag()(c, next);
180});
181
182// Cache-Control middleware — sets sensible defaults on public, anonymous
183// requests. Crontech (when wired as our edge layer) and downstream
184// browsers will honor these. Auth'd users get private,no-store
185// automatically — we never cache responses tied to a session.
186app.use("*", async (c, next) => {
187 await next();
188 // Don't overwrite explicit headers set by route handlers — BUT the
189 // ETag middleware unconditionally sets "private, no-cache, must-
190 // revalidate" so we have to treat that specific value as "no
191 // policy chosen yet" and apply ours. Any route that explicitly set
192 // a different cache-control wins.
193 const existing = c.res.headers.get("cache-control");
194 const etagDefault =
195 existing === "private, no-cache, must-revalidate" ||
196 existing === "no-cache";
197 if (existing && !etagDefault) return;
198 // Anything past auth: private + no-store (avoid leaking session
199 // content into shared caches). softAuth runs before this on the
200 // request, but the response side is what we're stamping.
201 const hasSession = c.req.header("cookie")?.includes("session=") ?? false;
202 const p = c.req.path;
203 // Always private for known-authed paths regardless of cookie.
204 if (
205 p.startsWith("/admin") ||
206 p.startsWith("/settings") ||
207 p.startsWith("/dashboard") ||
208 p.startsWith("/notifications") ||
209 p.startsWith("/connect/") ||
210 hasSession
211 ) {
212 c.res.headers.set("cache-control", "private, no-store");
213 return;
214 }
215 // Public marketing surfaces — short edge cache, longer browser cache,
216 // stale-while-revalidate so the user never waits on a stale fetch.
217 const isMarketing =
218 p === "/" ||
219 p === "/features" ||
220 p === "/pricing" ||
221 p === "/about" ||
222 p === "/vs-github" ||
223 p === "/explore" ||
224 p === "/help" ||
225 p === "/changelog" ||
226 p.startsWith("/legal/") ||
227 p === "/terms" ||
228 p === "/privacy" ||
229 p === "/acceptable-use" ||
230 p.startsWith("/docs/");
231 if (isMarketing) {
232 c.res.headers.set(
233 "cache-control",
234 "public, max-age=60, s-maxage=300, stale-while-revalidate=86400"
235 );
236 return;
237 }
238 // Public repo browse pages — cache aggressively. Edge invalidates
239 // on push via the post-receive hook (future Crontech surge purge).
240 if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") {
241 c.res.headers.set(
242 "cache-control",
243 "public, max-age=30, s-maxage=120, stale-while-revalidate=600"
244 );
245 return;
246 }
247 // Default: don't cache anything we haven't explicitly opted in.
248 c.res.headers.set("cache-control", "private, no-store");
249});
05b973eClaude250// Logger only on non-git routes to avoid overhead on clone/push
251app.use("*", async (c, next) => {
252 if (c.req.path.includes(".git/")) return next();
253 return logger()(c, next);
254});
79136bbClaude255app.use("/api/*", cors());
bf19c50Test User256// Global softAuth — populates c.get("user") for every downstream middleware
257// + route. This was previously per-route, which meant rate-limit middleware
258// (and anything else inspecting auth state) always saw a null user. Keep
259// individual routes free to add requireAuth on top for hard gating; this
260// just establishes the user object cheaply.
261app.use("*", softAuth);
290ea77Claude262
36cc17aClaude263// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude264// pre-redesign markup. JSON / static assets keep their own cache rules; only
265// text/html responses get the no-cache stamp. Without this, every push to
266// main left users staring at cached 80s-looking pages from before the design
267// landed.
36cc17aClaude268//
269// We deliberately use `private, no-cache, must-revalidate` rather than
270// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
271// which makes every Back/Forward press a cold server round-trip — that
272// contributed to the "every nav feels like a fresh login" UX complaint.
273// `no-cache` still revalidates on direct fetch but lets bfcache hold the
274// page in memory between navigations.
290ea77Claude275app.use("*", async (c, next) => {
276 await next();
277 const ct = c.res.headers.get("content-type") || "";
278 if (ct.startsWith("text/html")) {
36cc17aClaude279 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude280 }
281});
826eccfTest User282// Rate-limit API + auth endpoints.
283//
a41e675Test User284// `/api/*`: 1000/min per IP — generous so an admin clicking around the
285// operator console (or a CDN/proxy concentrating multiple users behind one
286// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
287// rate limits below, not this one.
288//
289// `authedMultiplier` is set but only fires when an upstream middleware has
290// already populated c.get("user") — most app.use() chains apply softAuth
291// per-route, so the multiplier is best-effort. Keep the anonymous base
292// high enough that humans never feel it.
293//
294// Skip-paths: dashboard plumbing endpoints that the layout polls on a
295// fixed cadence and that we don't want consuming any bucket:
296// /api/version — layout polls every 15s
826eccfTest User297// /api/notifications/count — nav bell unread-count fetcher
298// /pwa/vapid-public-key — fetched once per push-notification opt-in
299app.use(
300 "/api/*",
a41e675Test User301 rateLimit(1000, 60_000, "api", {
826eccfTest User302 authedMultiplier: 4,
303 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
304 })
305);
0316dbbClaude306app.use("/login", rateLimit(20, 60_000, "login"));
307app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude308// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
309app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User310// BLOCK Q2 — throttle magic-link sign-in for the same reason.
311app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude312
59b6fb2Claude313// CSRF protection — set token on all requests, validate on mutations
314app.use("*", csrfToken);
315app.use("*", csrfProtect);
316
45e31d0Claude317// Rate limit auth routes
318app.use("/login", authRateLimit);
319app.use("/register", authRateLimit);
320
59b6fb2Claude321// Rate limit git operations
322app.use("/:owner/:repo.git/*", gitRateLimit);
323
324// Rate limit search
325app.use("/:owner/:repo/search", searchRateLimit);
326app.use("/explore", searchRateLimit);
79136bbClaude327
328// Git Smart HTTP protocol routes (must be before web routes)
329app.route("/", gitRoutes);
330
45e31d0Claude331// REST API v1 (legacy)
79136bbClaude332app.route("/", apiRoutes);
333
52ad8b1Claude334// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
335// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
336// router's catch-shape, and BEFORE adminRoutes so the live /demo page
337// wins over the legacy /demo redirect in src/routes/admin.tsx.
338app.route("/", demoRoutes);
339
0316dbbClaude340// REST API v2 (basePath /api/v2)
341app.route("/", apiV2Routes);
342
e75eddcClaude343// Agent multiplayer v1 — /api/v2/agents/* (sessions, leases, usage).
344// Mounted alongside apiV2Routes (its own basePath, no path conflict).
345app.route("/", agentsRoutes);
346
ad6d4adClaude347// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
348app.route("/", hookRoutes);
21f8dbdClaude349app.route("/api/events", eventsRoutes);
ad6d4adClaude350
45e31d0Claude351// API documentation
352app.route("/", apiDocsRoutes);
4a80519Claude353app.route("/", buildAgentSpecRoutes);
a6ff0f2Claude354// PR command center — global PR dashboard with AI/GateTest/auto-merge signal
355app.route("/", pullsDashboardRoutes);
e9aa4d8Claude356// Issue command center — global issue dashboard with AI-triage + autopilot signal
357app.route("/", issuesDashboardRoutes);
358// Personal activity timeline — every event across the user's repos, with
359// AI-driven events surfaced separately (the Gluecron differentiator).
360app.route("/", activityRoutes);
361// Unified inbox — mentions + review requests + CI failures + AI events in one timeline
362app.route("/", inboxRoutes);
56801e1Claude363// AI standup feed — daily / weekly Claude-generated team brief
364app.route("/", standupRoutes);
79136bbClaude365
366// Auth routes (register, login, logout)
367app.route("/", authRoutes);
368
c63b860Claude369// BLOCK P1 — Password reset (forgot-password + reset-password)
370app.route("/", passwordResetRoutes);
371
372// BLOCK P2 — Email verification (verify-email + resend)
373app.route("/", emailVerificationRoutes);
374
cd4f63bTest User375// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
376app.route("/", magicLinkRoutes);
377
79136bbClaude378// Settings routes (profile, SSH keys)
379app.route("/", settingsRoutes);
380
7298a17Claude381// 2FA / TOTP settings (Block B4)
382app.route("/", settings2faRoutes);
383
e75eddcClaude384// Agent multiplayer — /settings/agents management UI
385app.route("/", settingsAgentsRoutes);
386
1d4ff60Claude387// Chat integrations — Slack / Discord / Teams (/settings/integrations
388// + /api/v2/integrations/{slack,discord}/*). See src/lib/chat-bot.ts.
389app.route("/", settingsIntegrationsRoutes);
390app.route("/", integrationsChatRoutes);
391
2df1f8cClaude392// WebAuthn / passkey routes (Block B5)
393app.route("/", passkeyRoutes);
394
058d752Claude395// OAuth 2.0 provider (Block B6)
396app.route("/", oauthRoutes);
397app.route("/", developerAppsRoutes);
398
6fc53bdClaude399// Theme toggle (dark/light cookie)
400app.route("/", themeRoutes);
401
402// Audit log UI
403app.route("/", auditRoutes);
404
405// Reactions API (issues, PRs, comments)
406app.route("/", reactionRoutes);
407
24cf2caClaude408// Saved replies (per-user canned comment templates)
409app.route("/", savedReplyRoutes);
410
411// Environments + deployment history UI
412app.route("/", deploymentRoutes);
413
6563f0aClaude414// Organizations + teams (Block B1)
415app.route("/", orgRoutes);
416
c81ab7aClaude417// API tokens
418app.route("/", tokenRoutes);
419
59b6fb2Claude420// Notifications
3ef4c9dClaude421app.route("/", notificationRoutes);
422
79136bbClaude423// Repo settings (description, visibility, delete)
424app.route("/", repoSettings);
425
23d1a81Claude426// Repo collaborators (add/list/remove)
427app.route("/", collaboratorRoutes);
428
04f6b7fClaude429// Team-based repo collaborators (invite a whole team)
430app.route("/", teamCollaboratorRoutes);
431
432// Collaborator invite accept flow (token-based)
433app.route("/", invitesRoutes);
434
435// Real-time SSE endpoint (topic-based live updates)
436app.route("/", liveEventsRoutes);
437
3c03977Claude438// PR live co-editing — presence + cursors + content sync via SSE.
439app.route("/", prLiveRoutes);
440
c81ab7aClaude441// Webhooks management
442app.route("/", webhookRoutes);
443
79136bbClaude444// Compare view (branch diffs)
445app.route("/", compareRoutes);
446
447// Issue tracker
448app.route("/", issueRoutes);
449
0074234Claude450// Pull requests
451app.route("/", pullRoutes);
79ed944Claude452// PR sandboxes — runnable per-PR environments. Migration 0067.
453app.route("/", prSandboxRoutes);
0074234Claude454
c81ab7aClaude455// Fork
456app.route("/", forkRoutes);
457
0074234Claude458// Web file editor
459app.route("/", editorRoutes);
460
43de941Claude461// Contributors
462app.route("/", contributorRoutes);
463
699e5c7Claude464// Health liveness + metrics endpoints
2c34075Claude465app.route("/", healthRoutes);
466
f295f78Dictation App467// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
468app.route("/api/platform-status", platformStatus);
469
52ad8b1Claude470// Block L4 — Public stats counters (powers landing-page social proof)
471app.route("/", publicStatsRoutes);
472
473// Block L3 — Live /demo page + /api/v2/demo/* endpoints
474app.route("/", demoRoutes);
475
2316be6Claude476// Public /status — human-readable platform health page
477app.route("/", statusRoutes);
478
b1be050CC LABS App479// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
480// Mounted near the public status route so the two surfaces are visible
481// side-by-side; routes are gated by isSiteAdmin internally.
482app.route("/", adminStatusRoutes);
483
80bed05Claude484// /help — quickstart + API cheatsheet
485app.route("/", helpRoutes);
486
5f2e749Claude487// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
488// so the new editorial pricing layout wins the route; the legacy marketing
489// pricing remains as a safety net but is shadowed at the router.
490app.route("/", pricingRoutes);
491
b0148e9Claude492// /pricing, /features, /about — marketing surface
493app.route("/", marketingRoutes);
494
5618f9aClaude495// SEO: robots.txt + sitemap.xml
496app.route("/", seoRoutes);
497
05cdb85Claude498// /api/version — live build SHA + uptime; client poller uses this to
499// surface 'New version available — reload' banners on deploy.
500app.route("/", versionRoutes);
501
699e5c7Claude502// Health dashboard (per-repo health page)
503app.route("/", healthDashboardRoutes);
504
9dd96b9Test User505// Block R1 — site-admin operations console. MUST be mounted BEFORE
506// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
507// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
508app.route("/", adminOpsRoutes);
f2c00b4CC LABS App509// BLOCK W — Self-host status + bootstrap dashboard.
510app.route("/", adminSelfHostRoutes);
826eccfTest User511// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
512app.route("/", adminDiagnoseRoutes);
9dd96b9Test User513
16b325cClaude514// Insights (time-travel, dependencies, rollback)
515app.route("/", insightRoutes);
516
f1ab587Claude517// Command center dashboard
518app.route("/", dashboardRoutes);
519
36b4cbdClaude520// Legal pages (terms, privacy, AUP)
521app.route("/", legalRoutes);
4b66018Claude522// Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}.
523// The main `legal.tsx` serves the short canonical paths (/terms, /privacy,
524// /acceptable-use); these are the formal versions that the legal pages
525// internally link to each other.
526app.route("/", legalTermsRoutes);
527app.route("/", legalPrivacyRoutes);
528app.route("/", legalAcceptableUseRoutes);
529app.route("/", legalDmcaRoutes);
36b4cbdClaude530
bdbd0deClaude531// GitHub import / migration
532app.route("/", importRoutes);
14c3cc8Claude533app.route("/", importBulkRoutes);
f390cfaCC LABS App534app.route("/", importSecretsRoutes);
14c3cc8Claude535app.route("/", migrationRoutes);
536
537// Spec-to-PR (experimental AI-generated draft PRs)
538app.route("/", specsRoutes);
23d0abfClaude539app.route("/", refactorRoutes);
bdbd0deClaude540
c81ab7aClaude541// Explore page
542app.route("/", exploreRoutes);
543
59b6fb2Claude544// Onboarding
545app.route("/", onboardingRoutes);
546
0316dbbClaude547// Admin + feature routes
548app.route("/", adminRoutes);
509c376Claude549app.route("/", adminIntegrationsRoutes);
79ed944Claude550app.route("/", adminAdvancementRoutes);
f764c07Claude551app.route("/", adminDeploysRoutes);
552app.route("/", adminDeploysPageRoutes);
9dd96b9Test User553// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude554app.route("/", advisoriesRoutes);
555app.route("/", aiChangelogRoutes);
556app.route("/", aiExplainRoutes);
557app.route("/", aiTestsRoutes);
558app.route("/", askRoutes);
38d31d3Claude559app.route("/", repoChatRoutes);
0316dbbClaude560app.route("/", billingRoutes);
8809b87Claude561app.route("/", billingUsageRoutes);
6778ad2Claude562app.route("/", stripeWebhookRoutes);
0316dbbClaude563app.route("/", codeScanningRoutes);
564app.route("/", commitStatusesRoutes);
565app.route("/", copilotRoutes);
566app.route("/", depUpdaterRoutes);
567app.route("/", depsRoutes);
568app.route("/", discussionsRoutes);
569app.route("/", environmentsRoutes);
4bbacbeClaude570app.route("/", previewsRoutes);
79ed944Claude571app.route("/", docsTrackingRoutes);
0316dbbClaude572app.route("/", followsRoutes);
573app.route("/", gatesRoutes);
574app.route("/", gistsRoutes);
575app.route("/", graphqlRoutes);
2c2163eClaude576app.route("/", mcpRoutes);
0316dbbClaude577app.route("/", marketplaceRoutes);
578app.route("/", mergeQueueRoutes);
579app.route("/", mirrorsRoutes);
580app.route("/", orgInsightsRoutes);
581app.route("/", packagesRoutes);
582app.route("/", packagesApiRoutes);
583app.route("/", pagesRoutes);
584app.route("/", projectsRoutes);
585app.route("/", protectedTagsRoutes);
586app.route("/", pwaRoutes);
46d6165Claude587app.route("/", installRoutes);
cd4f63bTest User588// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
589app.route("/", dxtRoutes);
662ce86Claude590// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
591// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
592app.route("/", connectClaudeRoutes);
0316dbbClaude593app.route("/", releasesRoutes);
594app.route("/", requiredChecksRoutes);
595app.route("/", rulesetsRoutes);
596app.route("/", searchRoutes);
597app.route("/", semanticSearchRoutes);
598app.route("/", signingKeysRoutes);
599app.route("/", sponsorsRoutes);
600app.route("/", ssoRoutes);
46d6165Claude601app.route("/", githubOauthRoutes);
582cdacClaude602app.route("/", googleOauthRoutes);
0316dbbClaude603app.route("/", symbolsRoutes);
604app.route("/", templatesRoutes);
605app.route("/", trafficRoutes);
606app.route("/", wikisRoutes);
607app.route("/", workflowsRoutes);
5ff9cc2Claude608app.route("/", workflowArtifactsRoutes);
609app.route("/", workflowSecretsRoutes);
46d6165Claude610app.route("/", sleepModeRoutes);
52ad8b1Claude611app.route("/", vsGithubRoutes);
0316dbbClaude612
45f3b73Claude613// Voice-to-PR — phone-first dictation → spec or issue
614app.route("/", voiceRoutes);
615
cd4f63bTest User616// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
617// before the web catch-all so the bare `/play` literal wins over the
618// `/:owner` user-profile route.
619app.route("/", playgroundRoutes);
620
79136bbClaude621// Web UI (catch-all, must be last)
622app.route("/", webRoutes);
623
c63b860Claude624// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
625// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude626app.notFound((c) => {
36cc17aClaude627 const user = c.get("user") ?? null;
79136bbClaude628 return c.html(
c63b860Claude629 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude630 404
631 );
632});
633
c63b860Claude634// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
635// view. Trace block only shown outside production.
79136bbClaude636app.onError((err, c) => {
80bed05Claude637 reportError(err, {
638 requestId: c.get("requestId"),
639 path: c.req.path,
640 method: c.req.method,
641 });
c63b860Claude642 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
643 // back to the context value set by request-context middleware.
644 const requestId =
645 c.req.header("x-request-id") ||
646 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude647 const user = c.get("user") ?? null;
c63b860Claude648 const trace =
649 process.env.NODE_ENV !== "production" && err && err.message
650 ? err.message
651 : undefined;
79136bbClaude652 return c.html(
c63b860Claude653 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude654 500
655 );
656});
657
658export default app;