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.tsxBlame642 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";
27import agentsRoutes from "./routes/agents";
79136bbClaude28import issueRoutes from "./routes/issues";
29import repoSettings from "./routes/repo-settings";
23d1a81Claude30import collaboratorRoutes from "./routes/collaborators";
04f6b7fClaude31import teamCollaboratorRoutes from "./routes/team-collaborators";
32import invitesRoutes from "./routes/invites";
33import liveEventsRoutes from "./routes/live-events";
3c03977Claude34import prLiveRoutes from "./routes/pr-live";
79136bbClaude35import compareRoutes from "./routes/compare";
0074234Claude36import pullRoutes from "./routes/pulls";
37import editorRoutes from "./routes/editor";
c81ab7aClaude38import forkRoutes from "./routes/fork";
39import webhookRoutes from "./routes/webhooks";
40import exploreRoutes from "./routes/explore";
41import tokenRoutes from "./routes/tokens";
43de941Claude42import contributorRoutes from "./routes/contributors";
699e5c7Claude43import healthRoutes from "./routes/health-probe";
44import healthDashboardRoutes from "./routes/health";
2316be6Claude45import statusRoutes from "./routes/status";
b1be050CC LABS App46import adminStatusRoutes from "./routes/admin-status";
80bed05Claude47import helpRoutes from "./routes/help";
b0148e9Claude48import marketingRoutes from "./routes/marketing";
5f2e749Claude49import pricingRoutes from "./routes/pricing";
5618f9aClaude50import seoRoutes from "./routes/seo";
05cdb85Claude51import versionRoutes from "./routes/version";
f295f78Dictation App52import { platformStatus } from "./routes/platform-status";
52ad8b1Claude53import publicStatsRoutes from "./routes/public-stats";
54import demoRoutes from "./routes/demo";
16b325cClaude55import insightRoutes from "./routes/insights";
f1ab587Claude56import dashboardRoutes from "./routes/dashboard";
36b4cbdClaude57import legalRoutes from "./routes/legal";
4b66018Claude58import legalDmcaRoutes from "./routes/legal/dmca";
59import legalTermsRoutes from "./routes/legal/terms";
60import legalPrivacyRoutes from "./routes/legal/privacy";
61import legalAcceptableUseRoutes from "./routes/legal/acceptable-use";
bdbd0deClaude62import importRoutes from "./routes/import";
14c3cc8Claude63import importBulkRoutes from "./routes/import-bulk";
f390cfaCC LABS App64import importSecretsRoutes from "./routes/import-secrets";
14c3cc8Claude65import migrationRoutes from "./routes/migrations";
66import specsRoutes from "./routes/specs";
23d0abfClaude67import refactorRoutes from "./routes/refactors";
79136bbClaude68import webRoutes from "./routes/web";
0316dbbClaude69import hookRoutes from "./routes/hooks";
70import eventsRoutes from "./routes/events";
71import passkeyRoutes from "./routes/passkeys";
72import oauthRoutes from "./routes/oauth";
73import developerAppsRoutes from "./routes/developer-apps";
74import themeRoutes from "./routes/theme";
75import auditRoutes from "./routes/audit";
76import reactionRoutes from "./routes/reactions";
77import savedReplyRoutes from "./routes/saved-replies";
78import deploymentRoutes from "./routes/deployments";
79import orgRoutes from "./routes/orgs";
80import notificationRoutes from "./routes/notifications";
81import onboardingRoutes from "./routes/onboarding";
82import adminRoutes from "./routes/admin";
f764c07Claude83import adminDeploysRoutes from "./routes/admin-deploys";
84import adminDeploysPageRoutes from "./routes/admin-deploys-page";
9dd96b9Test User85import adminOpsRoutes from "./routes/admin-ops";
f2c00b4CC LABS App86import adminSelfHostRoutes from "./routes/admin-self-host";
826eccfTest User87import adminDiagnoseRoutes from "./routes/admin-diagnose";
509c376Claude88import adminIntegrationsRoutes from "./routes/admin-integrations";
0316dbbClaude89import advisoriesRoutes from "./routes/advisories";
90import aiChangelogRoutes from "./routes/ai-changelog";
91import aiExplainRoutes from "./routes/ai-explain";
92import aiTestsRoutes from "./routes/ai-tests";
93import askRoutes from "./routes/ask";
38d31d3Claude94import repoChatRoutes from "./routes/repo-chat";
0316dbbClaude95import billingRoutes from "./routes/billing";
6778ad2Claude96import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude97import codeScanningRoutes from "./routes/code-scanning";
98import commitStatusesRoutes from "./routes/commit-statuses";
99import copilotRoutes from "./routes/copilot";
100import depUpdaterRoutes from "./routes/dep-updater";
101import depsRoutes from "./routes/deps";
102import discussionsRoutes from "./routes/discussions";
103import environmentsRoutes from "./routes/environments";
4bbacbeClaude104import previewsRoutes from "./routes/previews";
0316dbbClaude105import followsRoutes from "./routes/follows";
106import gatesRoutes from "./routes/gates";
107import gistsRoutes from "./routes/gists";
108import graphqlRoutes from "./routes/graphql";
2c2163eClaude109import mcpRoutes from "./routes/mcp";
0316dbbClaude110import marketplaceRoutes from "./routes/marketplace";
111import mergeQueueRoutes from "./routes/merge-queue";
112import mirrorsRoutes from "./routes/mirrors";
113import orgInsightsRoutes from "./routes/org-insights";
114import packagesRoutes from "./routes/packages";
115import packagesApiRoutes from "./routes/packages-api";
116import pagesRoutes from "./routes/pages";
117import projectsRoutes from "./routes/projects";
118import protectedTagsRoutes from "./routes/protected-tags";
119import pwaRoutes from "./routes/pwa";
46d6165Claude120import installRoutes from "./routes/install";
cd4f63bTest User121import dxtRoutes from "./routes/dxt";
662ce86Claude122import connectClaudeRoutes from "./routes/connect-claude";
0316dbbClaude123import releasesRoutes from "./routes/releases";
124import requiredChecksRoutes from "./routes/required-checks";
125import rulesetsRoutes from "./routes/rulesets";
126import searchRoutes from "./routes/search";
127import semanticSearchRoutes from "./routes/semantic-search";
128import signingKeysRoutes from "./routes/signing-keys";
129import sponsorsRoutes from "./routes/sponsors";
130import ssoRoutes from "./routes/sso";
46d6165Claude131import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude132import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude133import symbolsRoutes from "./routes/symbols";
134import templatesRoutes from "./routes/templates";
135import trafficRoutes from "./routes/traffic";
136import wikisRoutes from "./routes/wikis";
137import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude138import workflowArtifactsRoutes from "./routes/workflow-artifacts";
139import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude140import sleepModeRoutes from "./routes/sleep-mode";
56801e1Claude141import standupRoutes from "./routes/standups";
52ad8b1Claude142import vsGithubRoutes from "./routes/vs-github";
45f3b73Claude143import voiceRoutes from "./routes/voice-to-pr";
cd4f63bTest User144import playgroundRoutes from "./routes/playground";
59b6fb2Claude145import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
146import { csrfToken, csrfProtect } from "./middleware/csrf";
79136bbClaude147
2316901Claude148import type { AuthEnv } from "./middleware/auth";
bf19c50Test User149import { softAuth } from "./middleware/auth";
2316901Claude150
151const app = new Hono<AuthEnv>();
79136bbClaude152
3ef4c9dClaude153// Request context (request ID, start time) runs before everything else
154app.use("*", requestContext);
05b973eClaude155// Middleware — compression first (wraps all responses)
156app.use("*", compress());
f1ffd50Claude157
158// ETag middleware — returns 304 Not Modified on unchanged responses.
159// Saves ~95% bandwidth on repeat visits. Skipped on git protocol +
160// SSE + the API surface where it would interfere with streaming.
161app.use("*", async (c, next) => {
162 const p = c.req.path;
163 if (
164 p.includes(".git/") ||
165 p.startsWith("/live-events") ||
166 p.startsWith("/api/events/deploy") ||
3c03977Claude167 p.startsWith("/admin/status") ||
168 // PR live co-editing SSE stream — never etag streaming responses.
169 /^\/api\/v2\/pulls\/[^/]+\/live(\/|$)/.test(p)
f1ffd50Claude170 ) {
171 return next();
172 }
173 return etag()(c, next);
174});
175
176// Cache-Control middleware — sets sensible defaults on public, anonymous
177// requests. Crontech (when wired as our edge layer) and downstream
178// browsers will honor these. Auth'd users get private,no-store
179// automatically — we never cache responses tied to a session.
180app.use("*", async (c, next) => {
181 await next();
182 // Don't overwrite explicit headers set by route handlers — BUT the
183 // ETag middleware unconditionally sets "private, no-cache, must-
184 // revalidate" so we have to treat that specific value as "no
185 // policy chosen yet" and apply ours. Any route that explicitly set
186 // a different cache-control wins.
187 const existing = c.res.headers.get("cache-control");
188 const etagDefault =
189 existing === "private, no-cache, must-revalidate" ||
190 existing === "no-cache";
191 if (existing && !etagDefault) return;
192 // Anything past auth: private + no-store (avoid leaking session
193 // content into shared caches). softAuth runs before this on the
194 // request, but the response side is what we're stamping.
195 const hasSession = c.req.header("cookie")?.includes("session=") ?? false;
196 const p = c.req.path;
197 // Always private for known-authed paths regardless of cookie.
198 if (
199 p.startsWith("/admin") ||
200 p.startsWith("/settings") ||
201 p.startsWith("/dashboard") ||
202 p.startsWith("/notifications") ||
203 p.startsWith("/connect/") ||
204 hasSession
205 ) {
206 c.res.headers.set("cache-control", "private, no-store");
207 return;
208 }
209 // Public marketing surfaces — short edge cache, longer browser cache,
210 // stale-while-revalidate so the user never waits on a stale fetch.
211 const isMarketing =
212 p === "/" ||
213 p === "/features" ||
214 p === "/pricing" ||
215 p === "/about" ||
216 p === "/vs-github" ||
217 p === "/explore" ||
218 p === "/help" ||
219 p === "/changelog" ||
220 p.startsWith("/legal/") ||
221 p === "/terms" ||
222 p === "/privacy" ||
223 p === "/acceptable-use" ||
224 p.startsWith("/docs/");
225 if (isMarketing) {
226 c.res.headers.set(
227 "cache-control",
228 "public, max-age=60, s-maxage=300, stale-while-revalidate=86400"
229 );
230 return;
231 }
232 // Public repo browse pages — cache aggressively. Edge invalidates
233 // on push via the post-receive hook (future Crontech surge purge).
234 if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") {
235 c.res.headers.set(
236 "cache-control",
237 "public, max-age=30, s-maxage=120, stale-while-revalidate=600"
238 );
239 return;
240 }
241 // Default: don't cache anything we haven't explicitly opted in.
242 c.res.headers.set("cache-control", "private, no-store");
243});
05b973eClaude244// Logger only on non-git routes to avoid overhead on clone/push
245app.use("*", async (c, next) => {
246 if (c.req.path.includes(".git/")) return next();
247 return logger()(c, next);
248});
79136bbClaude249app.use("/api/*", cors());
bf19c50Test User250// Global softAuth — populates c.get("user") for every downstream middleware
251// + route. This was previously per-route, which meant rate-limit middleware
252// (and anything else inspecting auth state) always saw a null user. Keep
253// individual routes free to add requireAuth on top for hard gating; this
254// just establishes the user object cheaply.
255app.use("*", softAuth);
290ea77Claude256
36cc17aClaude257// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude258// pre-redesign markup. JSON / static assets keep their own cache rules; only
259// text/html responses get the no-cache stamp. Without this, every push to
260// main left users staring at cached 80s-looking pages from before the design
261// landed.
36cc17aClaude262//
263// We deliberately use `private, no-cache, must-revalidate` rather than
264// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
265// which makes every Back/Forward press a cold server round-trip — that
266// contributed to the "every nav feels like a fresh login" UX complaint.
267// `no-cache` still revalidates on direct fetch but lets bfcache hold the
268// page in memory between navigations.
290ea77Claude269app.use("*", async (c, next) => {
270 await next();
271 const ct = c.res.headers.get("content-type") || "";
272 if (ct.startsWith("text/html")) {
36cc17aClaude273 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude274 }
275});
826eccfTest User276// Rate-limit API + auth endpoints.
277//
a41e675Test User278// `/api/*`: 1000/min per IP — generous so an admin clicking around the
279// operator console (or a CDN/proxy concentrating multiple users behind one
280// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
281// rate limits below, not this one.
282//
283// `authedMultiplier` is set but only fires when an upstream middleware has
284// already populated c.get("user") — most app.use() chains apply softAuth
285// per-route, so the multiplier is best-effort. Keep the anonymous base
286// high enough that humans never feel it.
287//
288// Skip-paths: dashboard plumbing endpoints that the layout polls on a
289// fixed cadence and that we don't want consuming any bucket:
290// /api/version — layout polls every 15s
826eccfTest User291// /api/notifications/count — nav bell unread-count fetcher
292// /pwa/vapid-public-key — fetched once per push-notification opt-in
293app.use(
294 "/api/*",
a41e675Test User295 rateLimit(1000, 60_000, "api", {
826eccfTest User296 authedMultiplier: 4,
297 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
298 })
299);
0316dbbClaude300app.use("/login", rateLimit(20, 60_000, "login"));
301app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude302// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
303app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User304// BLOCK Q2 — throttle magic-link sign-in for the same reason.
305app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude306
59b6fb2Claude307// CSRF protection — set token on all requests, validate on mutations
308app.use("*", csrfToken);
309app.use("*", csrfProtect);
310
45e31d0Claude311// Rate limit auth routes
312app.use("/login", authRateLimit);
313app.use("/register", authRateLimit);
314
59b6fb2Claude315// Rate limit git operations
316app.use("/:owner/:repo.git/*", gitRateLimit);
317
318// Rate limit search
319app.use("/:owner/:repo/search", searchRateLimit);
320app.use("/explore", searchRateLimit);
79136bbClaude321
322// Git Smart HTTP protocol routes (must be before web routes)
323app.route("/", gitRoutes);
324
45e31d0Claude325// REST API v1 (legacy)
79136bbClaude326app.route("/", apiRoutes);
327
52ad8b1Claude328// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
329// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
330// router's catch-shape, and BEFORE adminRoutes so the live /demo page
331// wins over the legacy /demo redirect in src/routes/admin.tsx.
332app.route("/", demoRoutes);
333
0316dbbClaude334// REST API v2 (basePath /api/v2)
335app.route("/", apiV2Routes);
336
e75eddcClaude337// Agent multiplayer v1 — /api/v2/agents/* (sessions, leases, usage).
338// Mounted alongside apiV2Routes (its own basePath, no path conflict).
339app.route("/", agentsRoutes);
340
ad6d4adClaude341// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
342app.route("/", hookRoutes);
21f8dbdClaude343app.route("/api/events", eventsRoutes);
ad6d4adClaude344
45e31d0Claude345// API documentation
346app.route("/", apiDocsRoutes);
4a80519Claude347app.route("/", buildAgentSpecRoutes);
a6ff0f2Claude348// PR command center — global PR dashboard with AI/GateTest/auto-merge signal
349app.route("/", pullsDashboardRoutes);
e9aa4d8Claude350// Issue command center — global issue dashboard with AI-triage + autopilot signal
351app.route("/", issuesDashboardRoutes);
352// Personal activity timeline — every event across the user's repos, with
353// AI-driven events surfaced separately (the Gluecron differentiator).
354app.route("/", activityRoutes);
355// Unified inbox — mentions + review requests + CI failures + AI events in one timeline
356app.route("/", inboxRoutes);
56801e1Claude357// AI standup feed — daily / weekly Claude-generated team brief
358app.route("/", standupRoutes);
79136bbClaude359
360// Auth routes (register, login, logout)
361app.route("/", authRoutes);
362
c63b860Claude363// BLOCK P1 — Password reset (forgot-password + reset-password)
364app.route("/", passwordResetRoutes);
365
366// BLOCK P2 — Email verification (verify-email + resend)
367app.route("/", emailVerificationRoutes);
368
cd4f63bTest User369// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
370app.route("/", magicLinkRoutes);
371
79136bbClaude372// Settings routes (profile, SSH keys)
373app.route("/", settingsRoutes);
374
7298a17Claude375// 2FA / TOTP settings (Block B4)
376app.route("/", settings2faRoutes);
377
e75eddcClaude378// Agent multiplayer — /settings/agents management UI
379app.route("/", settingsAgentsRoutes);
380
2df1f8cClaude381// WebAuthn / passkey routes (Block B5)
382app.route("/", passkeyRoutes);
383
058d752Claude384// OAuth 2.0 provider (Block B6)
385app.route("/", oauthRoutes);
386app.route("/", developerAppsRoutes);
387
6fc53bdClaude388// Theme toggle (dark/light cookie)
389app.route("/", themeRoutes);
390
391// Audit log UI
392app.route("/", auditRoutes);
393
394// Reactions API (issues, PRs, comments)
395app.route("/", reactionRoutes);
396
24cf2caClaude397// Saved replies (per-user canned comment templates)
398app.route("/", savedReplyRoutes);
399
400// Environments + deployment history UI
401app.route("/", deploymentRoutes);
402
6563f0aClaude403// Organizations + teams (Block B1)
404app.route("/", orgRoutes);
405
c81ab7aClaude406// API tokens
407app.route("/", tokenRoutes);
408
59b6fb2Claude409// Notifications
3ef4c9dClaude410app.route("/", notificationRoutes);
411
79136bbClaude412// Repo settings (description, visibility, delete)
413app.route("/", repoSettings);
414
23d1a81Claude415// Repo collaborators (add/list/remove)
416app.route("/", collaboratorRoutes);
417
04f6b7fClaude418// Team-based repo collaborators (invite a whole team)
419app.route("/", teamCollaboratorRoutes);
420
421// Collaborator invite accept flow (token-based)
422app.route("/", invitesRoutes);
423
424// Real-time SSE endpoint (topic-based live updates)
425app.route("/", liveEventsRoutes);
426
3c03977Claude427// PR live co-editing — presence + cursors + content sync via SSE.
428app.route("/", prLiveRoutes);
429
c81ab7aClaude430// Webhooks management
431app.route("/", webhookRoutes);
432
79136bbClaude433// Compare view (branch diffs)
434app.route("/", compareRoutes);
435
436// Issue tracker
437app.route("/", issueRoutes);
438
0074234Claude439// Pull requests
440app.route("/", pullRoutes);
441
c81ab7aClaude442// Fork
443app.route("/", forkRoutes);
444
0074234Claude445// Web file editor
446app.route("/", editorRoutes);
447
43de941Claude448// Contributors
449app.route("/", contributorRoutes);
450
699e5c7Claude451// Health liveness + metrics endpoints
2c34075Claude452app.route("/", healthRoutes);
453
f295f78Dictation App454// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
455app.route("/api/platform-status", platformStatus);
456
52ad8b1Claude457// Block L4 — Public stats counters (powers landing-page social proof)
458app.route("/", publicStatsRoutes);
459
460// Block L3 — Live /demo page + /api/v2/demo/* endpoints
461app.route("/", demoRoutes);
462
2316be6Claude463// Public /status — human-readable platform health page
464app.route("/", statusRoutes);
465
b1be050CC LABS App466// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
467// Mounted near the public status route so the two surfaces are visible
468// side-by-side; routes are gated by isSiteAdmin internally.
469app.route("/", adminStatusRoutes);
470
80bed05Claude471// /help — quickstart + API cheatsheet
472app.route("/", helpRoutes);
473
5f2e749Claude474// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
475// so the new editorial pricing layout wins the route; the legacy marketing
476// pricing remains as a safety net but is shadowed at the router.
477app.route("/", pricingRoutes);
478
b0148e9Claude479// /pricing, /features, /about — marketing surface
480app.route("/", marketingRoutes);
481
5618f9aClaude482// SEO: robots.txt + sitemap.xml
483app.route("/", seoRoutes);
484
05cdb85Claude485// /api/version — live build SHA + uptime; client poller uses this to
486// surface 'New version available — reload' banners on deploy.
487app.route("/", versionRoutes);
488
699e5c7Claude489// Health dashboard (per-repo health page)
490app.route("/", healthDashboardRoutes);
491
9dd96b9Test User492// Block R1 — site-admin operations console. MUST be mounted BEFORE
493// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
494// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
495app.route("/", adminOpsRoutes);
f2c00b4CC LABS App496// BLOCK W — Self-host status + bootstrap dashboard.
497app.route("/", adminSelfHostRoutes);
826eccfTest User498// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
499app.route("/", adminDiagnoseRoutes);
9dd96b9Test User500
16b325cClaude501// Insights (time-travel, dependencies, rollback)
502app.route("/", insightRoutes);
503
f1ab587Claude504// Command center dashboard
505app.route("/", dashboardRoutes);
506
36b4cbdClaude507// Legal pages (terms, privacy, AUP)
508app.route("/", legalRoutes);
4b66018Claude509// Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}.
510// The main `legal.tsx` serves the short canonical paths (/terms, /privacy,
511// /acceptable-use); these are the formal versions that the legal pages
512// internally link to each other.
513app.route("/", legalTermsRoutes);
514app.route("/", legalPrivacyRoutes);
515app.route("/", legalAcceptableUseRoutes);
516app.route("/", legalDmcaRoutes);
36b4cbdClaude517
bdbd0deClaude518// GitHub import / migration
519app.route("/", importRoutes);
14c3cc8Claude520app.route("/", importBulkRoutes);
f390cfaCC LABS App521app.route("/", importSecretsRoutes);
14c3cc8Claude522app.route("/", migrationRoutes);
523
524// Spec-to-PR (experimental AI-generated draft PRs)
525app.route("/", specsRoutes);
23d0abfClaude526app.route("/", refactorRoutes);
bdbd0deClaude527
c81ab7aClaude528// Explore page
529app.route("/", exploreRoutes);
530
59b6fb2Claude531// Onboarding
532app.route("/", onboardingRoutes);
533
0316dbbClaude534// Admin + feature routes
535app.route("/", adminRoutes);
509c376Claude536app.route("/", adminIntegrationsRoutes);
f764c07Claude537app.route("/", adminDeploysRoutes);
538app.route("/", adminDeploysPageRoutes);
9dd96b9Test User539// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude540app.route("/", advisoriesRoutes);
541app.route("/", aiChangelogRoutes);
542app.route("/", aiExplainRoutes);
543app.route("/", aiTestsRoutes);
544app.route("/", askRoutes);
38d31d3Claude545app.route("/", repoChatRoutes);
0316dbbClaude546app.route("/", billingRoutes);
6778ad2Claude547app.route("/", stripeWebhookRoutes);
0316dbbClaude548app.route("/", codeScanningRoutes);
549app.route("/", commitStatusesRoutes);
550app.route("/", copilotRoutes);
551app.route("/", depUpdaterRoutes);
552app.route("/", depsRoutes);
553app.route("/", discussionsRoutes);
554app.route("/", environmentsRoutes);
4bbacbeClaude555app.route("/", previewsRoutes);
0316dbbClaude556app.route("/", followsRoutes);
557app.route("/", gatesRoutes);
558app.route("/", gistsRoutes);
559app.route("/", graphqlRoutes);
2c2163eClaude560app.route("/", mcpRoutes);
0316dbbClaude561app.route("/", marketplaceRoutes);
562app.route("/", mergeQueueRoutes);
563app.route("/", mirrorsRoutes);
564app.route("/", orgInsightsRoutes);
565app.route("/", packagesRoutes);
566app.route("/", packagesApiRoutes);
567app.route("/", pagesRoutes);
568app.route("/", projectsRoutes);
569app.route("/", protectedTagsRoutes);
570app.route("/", pwaRoutes);
46d6165Claude571app.route("/", installRoutes);
cd4f63bTest User572// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
573app.route("/", dxtRoutes);
662ce86Claude574// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
575// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
576app.route("/", connectClaudeRoutes);
0316dbbClaude577app.route("/", releasesRoutes);
578app.route("/", requiredChecksRoutes);
579app.route("/", rulesetsRoutes);
580app.route("/", searchRoutes);
581app.route("/", semanticSearchRoutes);
582app.route("/", signingKeysRoutes);
583app.route("/", sponsorsRoutes);
584app.route("/", ssoRoutes);
46d6165Claude585app.route("/", githubOauthRoutes);
582cdacClaude586app.route("/", googleOauthRoutes);
0316dbbClaude587app.route("/", symbolsRoutes);
588app.route("/", templatesRoutes);
589app.route("/", trafficRoutes);
590app.route("/", wikisRoutes);
591app.route("/", workflowsRoutes);
5ff9cc2Claude592app.route("/", workflowArtifactsRoutes);
593app.route("/", workflowSecretsRoutes);
46d6165Claude594app.route("/", sleepModeRoutes);
52ad8b1Claude595app.route("/", vsGithubRoutes);
0316dbbClaude596
45f3b73Claude597// Voice-to-PR — phone-first dictation → spec or issue
598app.route("/", voiceRoutes);
599
cd4f63bTest User600// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
601// before the web catch-all so the bare `/play` literal wins over the
602// `/:owner` user-profile route.
603app.route("/", playgroundRoutes);
604
79136bbClaude605// Web UI (catch-all, must be last)
606app.route("/", webRoutes);
607
c63b860Claude608// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
609// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude610app.notFound((c) => {
36cc17aClaude611 const user = c.get("user") ?? null;
79136bbClaude612 return c.html(
c63b860Claude613 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude614 404
615 );
616});
617
c63b860Claude618// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
619// view. Trace block only shown outside production.
79136bbClaude620app.onError((err, c) => {
80bed05Claude621 reportError(err, {
622 requestId: c.get("requestId"),
623 path: c.req.path,
624 method: c.req.method,
625 });
c63b860Claude626 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
627 // back to the context value set by request-context middleware.
628 const requestId =
629 c.req.header("x-request-id") ||
630 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude631 const user = c.get("user") ?? null;
c63b860Claude632 const trace =
633 process.env.NODE_ENV !== "production" && err && err.message
634 ? err.message
635 : undefined;
79136bbClaude636 return c.html(
c63b860Claude637 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude638 500
639 );
640});
641
642export default app;