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.tsxBlame736 lines · 4 contributors
79136bbClaude1import { Hono } from "hono";
2import { logger } from "hono/logger";
3import { cors } from "hono/cors";
05b973eClaude4import { compress } from "hono/compress";
f1ffd50Claude5import { etag } from "hono/etag";
c63b860Claude6// BLOCK O2 — shared error-page surface (404 / 500 / 403).
7import { NotFoundPage, ServerErrorPage } from "./views/error-page";
80bed05Claude8import { reportError } from "./lib/observability";
3ef4c9dClaude9import { requestContext } from "./middleware/request-context";
10import { rateLimit } from "./middleware/rate-limit";
79136bbClaude11import gitRoutes from "./routes/git";
12import apiRoutes from "./routes/api";
45e31d0Claude13import apiV2Routes from "./routes/api-v2";
14import apiDocsRoutes from "./routes/api-docs";
4a80519Claude15import buildAgentSpecRoutes from "./routes/build-agent-spec";
a6ff0f2Claude16import pullsDashboardRoutes from "./routes/pulls-dashboard";
e9aa4d8Claude17import issuesDashboardRoutes from "./routes/issues-dashboard";
18import inboxRoutes from "./routes/inbox";
19import activityRoutes from "./routes/activity";
79136bbClaude20import authRoutes from "./routes/auth";
c63b860Claude21import passwordResetRoutes from "./routes/password-reset";
22import emailVerificationRoutes from "./routes/email-verification";
cd4f63bTest User23import magicLinkRoutes from "./routes/magic-link";
79136bbClaude24import settingsRoutes from "./routes/settings";
7298a17Claude25import settings2faRoutes from "./routes/settings-2fa";
e75eddcClaude26import settingsAgentsRoutes from "./routes/settings-agents";
1d4ff60Claude27import settingsIntegrationsRoutes from "./routes/settings-integrations";
28import integrationsChatRoutes from "./routes/integrations-chat";
e75eddcClaude29import agentsRoutes from "./routes/agents";
79136bbClaude30import issueRoutes from "./routes/issues";
cb5a796Claude31import commentModerationRoutes from "./routes/comment-moderation";
79136bbClaude32import repoSettings from "./routes/repo-settings";
23d1a81Claude33import collaboratorRoutes from "./routes/collaborators";
04f6b7fClaude34import teamCollaboratorRoutes from "./routes/team-collaborators";
35import invitesRoutes from "./routes/invites";
36import liveEventsRoutes from "./routes/live-events";
3c03977Claude37import prLiveRoutes from "./routes/pr-live";
79136bbClaude38import compareRoutes from "./routes/compare";
0074234Claude39import pullRoutes from "./routes/pulls";
79ed944Claude40import prSandboxRoutes from "./routes/pr-sandbox";
9b3a183Claude41import devEnvRoutes from "./routes/dev-env";
0074234Claude42import editorRoutes from "./routes/editor";
c81ab7aClaude43import forkRoutes from "./routes/fork";
44import webhookRoutes from "./routes/webhooks";
45import exploreRoutes from "./routes/explore";
46import tokenRoutes from "./routes/tokens";
43de941Claude47import contributorRoutes from "./routes/contributors";
699e5c7Claude48import healthRoutes from "./routes/health-probe";
49import healthDashboardRoutes from "./routes/health";
2316be6Claude50import statusRoutes from "./routes/status";
b1be050CC LABS App51import adminStatusRoutes from "./routes/admin-status";
80bed05Claude52import helpRoutes from "./routes/help";
e1fc7dbClaude53import changelogRoutes from "./routes/changelog";
b0148e9Claude54import marketingRoutes from "./routes/marketing";
5f2e749Claude55import pricingRoutes from "./routes/pricing";
5618f9aClaude56import seoRoutes from "./routes/seo";
05cdb85Claude57import versionRoutes from "./routes/version";
f295f78Dictation App58import { platformStatus } from "./routes/platform-status";
52ad8b1Claude59import publicStatsRoutes from "./routes/public-stats";
60import demoRoutes from "./routes/demo";
16b325cClaude61import insightRoutes from "./routes/insights";
8d1483cClaude62import doraRoutes from "./routes/dora";
f1ab587Claude63import dashboardRoutes from "./routes/dashboard";
36b4cbdClaude64import legalRoutes from "./routes/legal";
4b66018Claude65import legalDmcaRoutes from "./routes/legal/dmca";
66import legalTermsRoutes from "./routes/legal/terms";
67import legalPrivacyRoutes from "./routes/legal/privacy";
68import legalAcceptableUseRoutes from "./routes/legal/acceptable-use";
bdbd0deClaude69import importRoutes from "./routes/import";
14c3cc8Claude70import importBulkRoutes from "./routes/import-bulk";
f390cfaCC LABS App71import importSecretsRoutes from "./routes/import-secrets";
14c3cc8Claude72import migrationRoutes from "./routes/migrations";
73import specsRoutes from "./routes/specs";
23d0abfClaude74import refactorRoutes from "./routes/refactors";
79136bbClaude75import webRoutes from "./routes/web";
0316dbbClaude76import hookRoutes from "./routes/hooks";
77import eventsRoutes from "./routes/events";
78import passkeyRoutes from "./routes/passkeys";
79import oauthRoutes from "./routes/oauth";
80import developerAppsRoutes from "./routes/developer-apps";
81import themeRoutes from "./routes/theme";
82import auditRoutes from "./routes/audit";
83import reactionRoutes from "./routes/reactions";
84import savedReplyRoutes from "./routes/saved-replies";
85import deploymentRoutes from "./routes/deployments";
86import orgRoutes from "./routes/orgs";
87import notificationRoutes from "./routes/notifications";
88import onboardingRoutes from "./routes/onboarding";
89import adminRoutes from "./routes/admin";
f764c07Claude90import adminDeploysRoutes from "./routes/admin-deploys";
91import adminDeploysPageRoutes from "./routes/admin-deploys-page";
783dd46Claude92import adminServerTargetsRoutes from "./routes/admin-server-targets";
9aaa128Claude93import deployTargetsRoutes from "./routes/deploy-targets";
90c7531Claude94import claudeWebRoutes from "./routes/claude-web";
9dd96b9Test User95import adminOpsRoutes from "./routes/admin-ops";
f2c00b4CC LABS App96import adminSelfHostRoutes from "./routes/admin-self-host";
826eccfTest User97import adminDiagnoseRoutes from "./routes/admin-diagnose";
509c376Claude98import adminIntegrationsRoutes from "./routes/admin-integrations";
79ed944Claude99import adminAdvancementRoutes from "./routes/admin-advancement";
0316dbbClaude100import advisoriesRoutes from "./routes/advisories";
101import aiChangelogRoutes from "./routes/ai-changelog";
102import aiExplainRoutes from "./routes/ai-explain";
103import aiTestsRoutes from "./routes/ai-tests";
104import askRoutes from "./routes/ask";
38d31d3Claude105import repoChatRoutes from "./routes/repo-chat";
ee7e577Claude106import personalChatRoutes from "./routes/personal-chat";
0316dbbClaude107import billingRoutes from "./routes/billing";
8809b87Claude108import billingUsageRoutes from "./routes/billing-usage";
6778ad2Claude109import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude110import codeScanningRoutes from "./routes/code-scanning";
111import commitStatusesRoutes from "./routes/commit-statuses";
112import copilotRoutes from "./routes/copilot";
113import depUpdaterRoutes from "./routes/dep-updater";
114import depsRoutes from "./routes/deps";
115import discussionsRoutes from "./routes/discussions";
116import environmentsRoutes from "./routes/environments";
4bbacbeClaude117import previewsRoutes from "./routes/previews";
79ed944Claude118import docsTrackingRoutes from "./routes/docs-tracking";
0316dbbClaude119import followsRoutes from "./routes/follows";
120import gatesRoutes from "./routes/gates";
121import gistsRoutes from "./routes/gists";
122import graphqlRoutes from "./routes/graphql";
2c2163eClaude123import mcpRoutes from "./routes/mcp";
0316dbbClaude124import marketplaceRoutes from "./routes/marketplace";
5ca514aClaude125import marketplaceAgentsRoutes from "./routes/marketplace-agents";
0316dbbClaude126import mergeQueueRoutes from "./routes/merge-queue";
127import mirrorsRoutes from "./routes/mirrors";
128import orgInsightsRoutes from "./routes/org-insights";
129import packagesRoutes from "./routes/packages";
130import packagesApiRoutes from "./routes/packages-api";
131import pagesRoutes from "./routes/pages";
132import projectsRoutes from "./routes/projects";
133import protectedTagsRoutes from "./routes/protected-tags";
134import pwaRoutes from "./routes/pwa";
46d6165Claude135import installRoutes from "./routes/install";
cd4f63bTest User136import dxtRoutes from "./routes/dxt";
662ce86Claude137import connectClaudeRoutes from "./routes/connect-claude";
ebbb527Claude138import claudeDeployRoutes from "./routes/claude-deploy";
f5b9ef5Claude139import claudeIntegration from "./routes/claude-integration";
140import connectRoutes from "./routes/connect";
05ab9b1Claude141import pushWatchRoutes from "./routes/push-watch";
142import orgSecretsRoutes from "./routes/org-secrets";
0316dbbClaude143import releasesRoutes from "./routes/releases";
144import requiredChecksRoutes from "./routes/required-checks";
145import rulesetsRoutes from "./routes/rulesets";
146import searchRoutes from "./routes/search";
147import semanticSearchRoutes from "./routes/semantic-search";
148import signingKeysRoutes from "./routes/signing-keys";
149import sponsorsRoutes from "./routes/sponsors";
150import ssoRoutes from "./routes/sso";
46d6165Claude151import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude152import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude153import symbolsRoutes from "./routes/symbols";
154import templatesRoutes from "./routes/templates";
155import trafficRoutes from "./routes/traffic";
156import wikisRoutes from "./routes/wikis";
157import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude158import workflowArtifactsRoutes from "./routes/workflow-artifacts";
159import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude160import sleepModeRoutes from "./routes/sleep-mode";
56801e1Claude161import standupRoutes from "./routes/standups";
52ad8b1Claude162import vsGithubRoutes from "./routes/vs-github";
45f3b73Claude163import voiceRoutes from "./routes/voice-to-pr";
cd4f63bTest User164import playgroundRoutes from "./routes/playground";
a2b3e99Claude165import crossRepoSearchRoutes from "./routes/cross-repo-search";
166import pushNotifRoutes from "./routes/push-notifications";
9fbe6cdClaude167import velocityRoutes from "./routes/velocity";
168import { staleBranchRoutes } from "./routes/stale-branches";
22f43f3Claude169import pulseRoutes from "./routes/pulse";
74d8c4dClaude170import healthScoreRoutes from "./routes/health-score";
171import hotFilesRoutes from "./routes/hot-files";
adf5e18Claude172import developerProgramRoutes from "./routes/developer-program";
59b6fb2Claude173import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
174import { csrfToken, csrfProtect } from "./middleware/csrf";
f5b9ef5Claude175import { noCache } from "./middleware/no-cache";
79136bbClaude176
2316901Claude177import type { AuthEnv } from "./middleware/auth";
bf19c50Test User178import { softAuth } from "./middleware/auth";
2316901Claude179
180const app = new Hono<AuthEnv>();
79136bbClaude181
3ef4c9dClaude182// Request context (request ID, start time) runs before everything else
183app.use("*", requestContext);
05b973eClaude184// Middleware — compression first (wraps all responses)
185app.use("*", compress());
f1ffd50Claude186
187// ETag middleware — returns 304 Not Modified on unchanged responses.
188// Saves ~95% bandwidth on repeat visits. Skipped on git protocol +
189// SSE + the API surface where it would interfere with streaming.
190app.use("*", async (c, next) => {
191 const p = c.req.path;
192 if (
193 p.includes(".git/") ||
194 p.startsWith("/live-events") ||
195 p.startsWith("/api/events/deploy") ||
3c03977Claude196 p.startsWith("/admin/status") ||
197 // PR live co-editing SSE stream — never etag streaming responses.
198 /^\/api\/v2\/pulls\/[^/]+\/live(\/|$)/.test(p)
f1ffd50Claude199 ) {
200 return next();
201 }
202 return etag()(c, next);
203});
204
205// Cache-Control middleware — sets sensible defaults on public, anonymous
206// requests. Crontech (when wired as our edge layer) and downstream
207// browsers will honor these. Auth'd users get private,no-store
208// automatically — we never cache responses tied to a session.
209app.use("*", async (c, next) => {
210 await next();
211 // Don't overwrite explicit headers set by route handlers — BUT the
212 // ETag middleware unconditionally sets "private, no-cache, must-
213 // revalidate" so we have to treat that specific value as "no
214 // policy chosen yet" and apply ours. Any route that explicitly set
215 // a different cache-control wins.
216 const existing = c.res.headers.get("cache-control");
217 const etagDefault =
218 existing === "private, no-cache, must-revalidate" ||
219 existing === "no-cache";
220 if (existing && !etagDefault) return;
221 // Anything past auth: private + no-store (avoid leaking session
222 // content into shared caches). softAuth runs before this on the
223 // request, but the response side is what we're stamping.
224 const hasSession = c.req.header("cookie")?.includes("session=") ?? false;
225 const p = c.req.path;
226 // Always private for known-authed paths regardless of cookie.
227 if (
228 p.startsWith("/admin") ||
229 p.startsWith("/settings") ||
230 p.startsWith("/dashboard") ||
231 p.startsWith("/notifications") ||
232 p.startsWith("/connect/") ||
233 hasSession
234 ) {
235 c.res.headers.set("cache-control", "private, no-store");
236 return;
237 }
238 // Public marketing surfaces — short edge cache, longer browser cache,
239 // stale-while-revalidate so the user never waits on a stale fetch.
240 const isMarketing =
241 p === "/" ||
242 p === "/features" ||
243 p === "/pricing" ||
244 p === "/about" ||
245 p === "/vs-github" ||
246 p === "/explore" ||
247 p === "/help" ||
248 p === "/changelog" ||
249 p.startsWith("/legal/") ||
250 p === "/terms" ||
251 p === "/privacy" ||
252 p === "/acceptable-use" ||
253 p.startsWith("/docs/");
254 if (isMarketing) {
255 c.res.headers.set(
256 "cache-control",
257 "public, max-age=60, s-maxage=300, stale-while-revalidate=86400"
258 );
259 return;
260 }
261 // Public repo browse pages — cache aggressively. Edge invalidates
262 // on push via the post-receive hook (future Crontech surge purge).
263 if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") {
264 c.res.headers.set(
265 "cache-control",
266 "public, max-age=30, s-maxage=120, stale-while-revalidate=600"
267 );
268 return;
269 }
270 // Default: don't cache anything we haven't explicitly opted in.
271 c.res.headers.set("cache-control", "private, no-store");
272});
05b973eClaude273// Logger only on non-git routes to avoid overhead on clone/push
274app.use("*", async (c, next) => {
275 if (c.req.path.includes(".git/")) return next();
276 return logger()(c, next);
277});
79136bbClaude278app.use("/api/*", cors());
bf19c50Test User279// Global softAuth — populates c.get("user") for every downstream middleware
280// + route. This was previously per-route, which meant rate-limit middleware
281// (and anything else inspecting auth state) always saw a null user. Keep
282// individual routes free to add requireAuth on top for hard gating; this
283// just establishes the user object cheaply.
284app.use("*", softAuth);
290ea77Claude285
36cc17aClaude286// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude287// pre-redesign markup. JSON / static assets keep their own cache rules; only
288// text/html responses get the no-cache stamp. Without this, every push to
289// main left users staring at cached 80s-looking pages from before the design
290// landed.
36cc17aClaude291//
292// We deliberately use `private, no-cache, must-revalidate` rather than
293// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
294// which makes every Back/Forward press a cold server round-trip — that
295// contributed to the "every nav feels like a fresh login" UX complaint.
296// `no-cache` still revalidates on direct fetch but lets bfcache hold the
297// page in memory between navigations.
290ea77Claude298app.use("*", async (c, next) => {
299 await next();
300 const ct = c.res.headers.get("content-type") || "";
301 if (ct.startsWith("text/html")) {
36cc17aClaude302 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude303 }
304});
826eccfTest User305// Rate-limit API + auth endpoints.
306//
a41e675Test User307// `/api/*`: 1000/min per IP — generous so an admin clicking around the
308// operator console (or a CDN/proxy concentrating multiple users behind one
309// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
310// rate limits below, not this one.
311//
312// `authedMultiplier` is set but only fires when an upstream middleware has
313// already populated c.get("user") — most app.use() chains apply softAuth
314// per-route, so the multiplier is best-effort. Keep the anonymous base
315// high enough that humans never feel it.
316//
317// Skip-paths: dashboard plumbing endpoints that the layout polls on a
318// fixed cadence and that we don't want consuming any bucket:
319// /api/version — layout polls every 15s
826eccfTest User320// /api/notifications/count — nav bell unread-count fetcher
321// /pwa/vapid-public-key — fetched once per push-notification opt-in
322app.use(
323 "/api/*",
a41e675Test User324 rateLimit(1000, 60_000, "api", {
826eccfTest User325 authedMultiplier: 4,
326 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
327 })
328);
0316dbbClaude329app.use("/login", rateLimit(20, 60_000, "login"));
330app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude331// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
332app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User333// BLOCK Q2 — throttle magic-link sign-in for the same reason.
334app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude335
59b6fb2Claude336// CSRF protection — set token on all requests, validate on mutations
337app.use("*", csrfToken);
338app.use("*", csrfProtect);
339
45e31d0Claude340// Rate limit auth routes
341app.use("/login", authRateLimit);
342app.use("/register", authRateLimit);
343
59b6fb2Claude344// Rate limit git operations
345app.use("/:owner/:repo.git/*", gitRateLimit);
346
347// Rate limit search
348app.use("/:owner/:repo/search", searchRateLimit);
349app.use("/explore", searchRateLimit);
79136bbClaude350
f5b9ef5Claude351// No-cache for HTML — ensures browsers and proxies never serve stale pages.
352// The middleware only stamps text/html responses so static assets keep
353// their own cache policies unchanged.
354app.use("*", noCache);
355
79136bbClaude356// Git Smart HTTP protocol routes (must be before web routes)
357app.route("/", gitRoutes);
358
45e31d0Claude359// REST API v1 (legacy)
79136bbClaude360app.route("/", apiRoutes);
361
52ad8b1Claude362// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
363// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
364// router's catch-shape, and BEFORE adminRoutes so the live /demo page
365// wins over the legacy /demo redirect in src/routes/admin.tsx.
366app.route("/", demoRoutes);
367
0316dbbClaude368// REST API v2 (basePath /api/v2)
369app.route("/", apiV2Routes);
370
e75eddcClaude371// Agent multiplayer v1 — /api/v2/agents/* (sessions, leases, usage).
372// Mounted alongside apiV2Routes (its own basePath, no path conflict).
373app.route("/", agentsRoutes);
374
ad6d4adClaude375// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
376app.route("/", hookRoutes);
21f8dbdClaude377app.route("/api/events", eventsRoutes);
ad6d4adClaude378
45e31d0Claude379// API documentation
380app.route("/", apiDocsRoutes);
4a80519Claude381app.route("/", buildAgentSpecRoutes);
a6ff0f2Claude382// PR command center — global PR dashboard with AI/GateTest/auto-merge signal
383app.route("/", pullsDashboardRoutes);
e9aa4d8Claude384// Issue command center — global issue dashboard with AI-triage + autopilot signal
385app.route("/", issuesDashboardRoutes);
386// Personal activity timeline — every event across the user's repos, with
387// AI-driven events surfaced separately (the Gluecron differentiator).
388app.route("/", activityRoutes);
389// Unified inbox — mentions + review requests + CI failures + AI events in one timeline
390app.route("/", inboxRoutes);
56801e1Claude391// AI standup feed — daily / weekly Claude-generated team brief
392app.route("/", standupRoutes);
79136bbClaude393
394// Auth routes (register, login, logout)
395app.route("/", authRoutes);
396
c63b860Claude397// BLOCK P1 — Password reset (forgot-password + reset-password)
398app.route("/", passwordResetRoutes);
399
400// BLOCK P2 — Email verification (verify-email + resend)
401app.route("/", emailVerificationRoutes);
402
cd4f63bTest User403// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
404app.route("/", magicLinkRoutes);
405
79136bbClaude406// Settings routes (profile, SSH keys)
407app.route("/", settingsRoutes);
408
7298a17Claude409// 2FA / TOTP settings (Block B4)
410app.route("/", settings2faRoutes);
411
e75eddcClaude412// Agent multiplayer — /settings/agents management UI
413app.route("/", settingsAgentsRoutes);
414
1d4ff60Claude415// Chat integrations — Slack / Discord / Teams (/settings/integrations
416// + /api/v2/integrations/{slack,discord}/*). See src/lib/chat-bot.ts.
417app.route("/", settingsIntegrationsRoutes);
418app.route("/", integrationsChatRoutes);
419
2df1f8cClaude420// WebAuthn / passkey routes (Block B5)
421app.route("/", passkeyRoutes);
422
058d752Claude423// OAuth 2.0 provider (Block B6)
424app.route("/", oauthRoutes);
425app.route("/", developerAppsRoutes);
426
6fc53bdClaude427// Theme toggle (dark/light cookie)
428app.route("/", themeRoutes);
429
430// Audit log UI
431app.route("/", auditRoutes);
432
433// Reactions API (issues, PRs, comments)
434app.route("/", reactionRoutes);
435
24cf2caClaude436// Saved replies (per-user canned comment templates)
437app.route("/", savedReplyRoutes);
438
439// Environments + deployment history UI
440app.route("/", deploymentRoutes);
441
6563f0aClaude442// Organizations + teams (Block B1)
443app.route("/", orgRoutes);
444
c81ab7aClaude445// API tokens
446app.route("/", tokenRoutes);
447
59b6fb2Claude448// Notifications
3ef4c9dClaude449app.route("/", notificationRoutes);
450
79136bbClaude451// Repo settings (description, visibility, delete)
452app.route("/", repoSettings);
453
23d1a81Claude454// Repo collaborators (add/list/remove)
455app.route("/", collaboratorRoutes);
456
04f6b7fClaude457// Team-based repo collaborators (invite a whole team)
458app.route("/", teamCollaboratorRoutes);
459
460// Collaborator invite accept flow (token-based)
461app.route("/", invitesRoutes);
462
463// Real-time SSE endpoint (topic-based live updates)
464app.route("/", liveEventsRoutes);
465
3c03977Claude466// PR live co-editing — presence + cursors + content sync via SSE.
467app.route("/", prLiveRoutes);
468
c81ab7aClaude469// Webhooks management
470app.route("/", webhookRoutes);
471
79136bbClaude472// Compare view (branch diffs)
473app.route("/", compareRoutes);
474
475// Issue tracker
476app.route("/", issueRoutes);
477
cb5a796Claude478// Comment moderation queue — owner-only `/:owner/:repo/comments/pending`
479// + per-row approve/reject/spam actions. Mounted before `pullRoutes` so
480// the `/:owner/:repo/comments/*` paths resolve before the broader PR
481// patterns kick in.
482app.route("/", commentModerationRoutes);
483
0074234Claude484// Pull requests
485app.route("/", pullRoutes);
79ed944Claude486// PR sandboxes — runnable per-PR environments. Migration 0067.
487app.route("/", prSandboxRoutes);
0074234Claude488
9b3a183Claude489// Cloud dev environments — hosted VS Code in the browser. Migration 0072.
490app.route("/", devEnvRoutes);
491
c81ab7aClaude492// Fork
493app.route("/", forkRoutes);
494
0074234Claude495// Web file editor
496app.route("/", editorRoutes);
497
43de941Claude498// Contributors
499app.route("/", contributorRoutes);
500
699e5c7Claude501// Health liveness + metrics endpoints
2c34075Claude502app.route("/", healthRoutes);
503
f295f78Dictation App504// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
505app.route("/api/platform-status", platformStatus);
506
52ad8b1Claude507// Block L4 — Public stats counters (powers landing-page social proof)
508app.route("/", publicStatsRoutes);
509
510// Block L3 — Live /demo page + /api/v2/demo/* endpoints
511app.route("/", demoRoutes);
512
2316be6Claude513// Public /status — human-readable platform health page
514app.route("/", statusRoutes);
515
b1be050CC LABS App516// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
517// Mounted near the public status route so the two surfaces are visible
518// side-by-side; routes are gated by isSiteAdmin internally.
519app.route("/", adminStatusRoutes);
520
80bed05Claude521// /help — quickstart + API cheatsheet
522app.route("/", helpRoutes);
523
5f2e749Claude524// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
525// so the new editorial pricing layout wins the route; the legacy marketing
526// pricing remains as a safety net but is shadowed at the router.
527app.route("/", pricingRoutes);
528
e1fc7dbClaude529// /changelog — manually curated platform release history
530app.route("/", changelogRoutes);
531
b0148e9Claude532// /pricing, /features, /about — marketing surface
533app.route("/", marketingRoutes);
534
adf5e18Claude535// /developer-program — partner + marketplace revenue-share page
536app.route("/", developerProgramRoutes);
537
5618f9aClaude538// SEO: robots.txt + sitemap.xml
539app.route("/", seoRoutes);
540
05cdb85Claude541// /api/version — live build SHA + uptime; client poller uses this to
542// surface 'New version available — reload' banners on deploy.
543app.route("/", versionRoutes);
544
699e5c7Claude545// Health dashboard (per-repo health page)
546app.route("/", healthDashboardRoutes);
547
9dd96b9Test User548// Block R1 — site-admin operations console. MUST be mounted BEFORE
549// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
550// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
551app.route("/", adminOpsRoutes);
f2c00b4CC LABS App552// BLOCK W — Self-host status + bootstrap dashboard.
553app.route("/", adminSelfHostRoutes);
826eccfTest User554// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
555app.route("/", adminDiagnoseRoutes);
9dd96b9Test User556
16b325cClaude557// Insights (time-travel, dependencies, rollback)
558app.route("/", insightRoutes);
559
8d1483cClaude560// DORA metrics page (/:owner/:repo/insights/dora)
561app.route("/", doraRoutes);
562
f1ab587Claude563// Command center dashboard
564app.route("/", dashboardRoutes);
565
36b4cbdClaude566// Legal pages (terms, privacy, AUP)
567app.route("/", legalRoutes);
4b66018Claude568// Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}.
569// The main `legal.tsx` serves the short canonical paths (/terms, /privacy,
570// /acceptable-use); these are the formal versions that the legal pages
571// internally link to each other.
572app.route("/", legalTermsRoutes);
573app.route("/", legalPrivacyRoutes);
574app.route("/", legalAcceptableUseRoutes);
575app.route("/", legalDmcaRoutes);
36b4cbdClaude576
bdbd0deClaude577// GitHub import / migration
578app.route("/", importRoutes);
14c3cc8Claude579app.route("/", importBulkRoutes);
f390cfaCC LABS App580app.route("/", importSecretsRoutes);
14c3cc8Claude581app.route("/", migrationRoutes);
582
583// Spec-to-PR (experimental AI-generated draft PRs)
584app.route("/", specsRoutes);
23d0abfClaude585app.route("/", refactorRoutes);
bdbd0deClaude586
c81ab7aClaude587// Explore page
588app.route("/", exploreRoutes);
589
59b6fb2Claude590// Onboarding
591app.route("/", onboardingRoutes);
592
0316dbbClaude593// Admin + feature routes
594app.route("/", adminRoutes);
509c376Claude595app.route("/", adminIntegrationsRoutes);
79ed944Claude596app.route("/", adminAdvancementRoutes);
f764c07Claude597app.route("/", adminDeploysRoutes);
598app.route("/", adminDeploysPageRoutes);
783dd46Claude599app.route("/", adminServerTargetsRoutes);
9aaa128Claude600app.route("/", deployTargetsRoutes);
90c7531Claude601app.route("/", claudeWebRoutes);
9dd96b9Test User602// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude603app.route("/", advisoriesRoutes);
604app.route("/", aiChangelogRoutes);
605app.route("/", aiExplainRoutes);
606app.route("/", aiTestsRoutes);
607app.route("/", askRoutes);
38d31d3Claude608app.route("/", repoChatRoutes);
ee7e577Claude609// Personal cross-repo chat — `/chat` (user-scoped). Mounted alongside
610// repoChatRoutes so the two surfaces share the catch-all priority.
611app.route("/", personalChatRoutes);
0316dbbClaude612app.route("/", billingRoutes);
8809b87Claude613app.route("/", billingUsageRoutes);
6778ad2Claude614app.route("/", stripeWebhookRoutes);
0316dbbClaude615app.route("/", codeScanningRoutes);
616app.route("/", commitStatusesRoutes);
617app.route("/", copilotRoutes);
618app.route("/", depUpdaterRoutes);
619app.route("/", depsRoutes);
620app.route("/", discussionsRoutes);
621app.route("/", environmentsRoutes);
4bbacbeClaude622app.route("/", previewsRoutes);
79ed944Claude623app.route("/", docsTrackingRoutes);
0316dbbClaude624app.route("/", followsRoutes);
625app.route("/", gatesRoutes);
626app.route("/", gistsRoutes);
627app.route("/", graphqlRoutes);
2c2163eClaude628app.route("/", mcpRoutes);
0316dbbClaude629app.route("/", marketplaceRoutes);
5ca514aClaude630app.route("/", marketplaceAgentsRoutes);
0316dbbClaude631app.route("/", mergeQueueRoutes);
632app.route("/", mirrorsRoutes);
633app.route("/", orgInsightsRoutes);
634app.route("/", packagesRoutes);
635app.route("/", packagesApiRoutes);
636app.route("/", pagesRoutes);
637app.route("/", projectsRoutes);
638app.route("/", protectedTagsRoutes);
639app.route("/", pwaRoutes);
46d6165Claude640app.route("/", installRoutes);
cd4f63bTest User641// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
642app.route("/", dxtRoutes);
662ce86Claude643// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
644// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
645app.route("/", connectClaudeRoutes);
f5b9ef5Claude646// Claude Code Integration Receiver — /api/claude/connect + /api/claude/session.
647app.route("/", claudeIntegration);
648// Connect guide — public onboarding page (/connect/claude-guide).
649app.route("/", connectRoutes);
05ab9b1Claude650// Push Watch — per-commit live status (gates + deploy + latency) at /:owner/:repo/push/:sha
651app.route("/", pushWatchRoutes);
652// Org Secrets Manager — BLOCK M2 — /orgs/:slug/settings/secrets
653app.route("/", orgSecretsRoutes);
a2b3e99Claude654// Cross-repo code search — BLOCK M3 — /search/code + /api/search/code
655app.route("/", crossRepoSearchRoutes);
656// Browser push notifications — BLOCK M4 — /settings/notifications/push + /api/push/*
657app.route("/", pushNotifRoutes);
9fbe6cdClaude658// Developer Velocity Dashboard — BLOCK M9 — /:owner/:repo/insights/velocity
659app.route("/", velocityRoutes);
660// Stale Branch Cleanup — BLOCK M10 — /:owner/:repo/branches/stale
661app.route("/", staleBranchRoutes);
22f43f3Claude662// Repository Pulse — BLOCK M12 — /:owner/:repo/pulse
663app.route("/", pulseRoutes);
74d8c4dClaude664// Repository Health Score — BLOCK M14 — /:owner/:repo/insights/health
665app.route("/", healthScoreRoutes);
666// Hot Files Heatmap — BLOCK M16 — /:owner/:repo/insights/hotfiles
667app.route("/", hotFilesRoutes);
ebbb527Claude668// Hosted Claude tool-use loops — paste loop, get endpoint, billing meter.
669// See src/routes/claude-deploy.tsx + src/lib/hosted-claude-loop.ts.
670app.route("/", claudeDeployRoutes);
0316dbbClaude671app.route("/", releasesRoutes);
672app.route("/", requiredChecksRoutes);
673app.route("/", rulesetsRoutes);
674app.route("/", searchRoutes);
675app.route("/", semanticSearchRoutes);
676app.route("/", signingKeysRoutes);
677app.route("/", sponsorsRoutes);
678app.route("/", ssoRoutes);
46d6165Claude679app.route("/", githubOauthRoutes);
582cdacClaude680app.route("/", googleOauthRoutes);
0316dbbClaude681app.route("/", symbolsRoutes);
682app.route("/", templatesRoutes);
683app.route("/", trafficRoutes);
684app.route("/", wikisRoutes);
685app.route("/", workflowsRoutes);
5ff9cc2Claude686app.route("/", workflowArtifactsRoutes);
687app.route("/", workflowSecretsRoutes);
46d6165Claude688app.route("/", sleepModeRoutes);
52ad8b1Claude689app.route("/", vsGithubRoutes);
0316dbbClaude690
45f3b73Claude691// Voice-to-PR — phone-first dictation → spec or issue
692app.route("/", voiceRoutes);
693
cd4f63bTest User694// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
695// before the web catch-all so the bare `/play` literal wins over the
696// `/:owner` user-profile route.
697app.route("/", playgroundRoutes);
698
79136bbClaude699// Web UI (catch-all, must be last)
700app.route("/", webRoutes);
701
c63b860Claude702// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
703// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude704app.notFound((c) => {
36cc17aClaude705 const user = c.get("user") ?? null;
79136bbClaude706 return c.html(
c63b860Claude707 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude708 404
709 );
710});
711
c63b860Claude712// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
713// view. Trace block only shown outside production.
79136bbClaude714app.onError((err, c) => {
80bed05Claude715 reportError(err, {
716 requestId: c.get("requestId"),
717 path: c.req.path,
718 method: c.req.method,
719 });
c63b860Claude720 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
721 // back to the context value set by request-context middleware.
722 const requestId =
723 c.req.header("x-request-id") ||
724 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude725 const user = c.get("user") ?? null;
c63b860Claude726 const trace =
727 process.env.NODE_ENV !== "production" && err && err.message
728 ? err.message
729 : undefined;
79136bbClaude730 return c.html(
c63b860Claude731 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude732 500
733 );
734});
735
736export default app;