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.tsxBlame860 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";
ef3fd93Claude30import agentPipelinesRoutes from "./routes/agent-pipelines";
79136bbClaude31import issueRoutes from "./routes/issues";
cb5a796Claude32import commentModerationRoutes from "./routes/comment-moderation";
79136bbClaude33import repoSettings from "./routes/repo-settings";
23d1a81Claude34import collaboratorRoutes from "./routes/collaborators";
04f6b7fClaude35import teamCollaboratorRoutes from "./routes/team-collaborators";
36import invitesRoutes from "./routes/invites";
37import liveEventsRoutes from "./routes/live-events";
3c03977Claude38import prLiveRoutes from "./routes/pr-live";
79136bbClaude39import compareRoutes from "./routes/compare";
0074234Claude40import pullRoutes from "./routes/pulls";
79ed944Claude41import prSandboxRoutes from "./routes/pr-sandbox";
9b3a183Claude42import devEnvRoutes from "./routes/dev-env";
0074234Claude43import editorRoutes from "./routes/editor";
6f2809fClaude44import aiEditorRoutes from "./routes/ai-editor";
c81ab7aClaude45import forkRoutes from "./routes/fork";
46import webhookRoutes from "./routes/webhooks";
47import exploreRoutes from "./routes/explore";
48import tokenRoutes from "./routes/tokens";
43de941Claude49import contributorRoutes from "./routes/contributors";
699e5c7Claude50import healthRoutes from "./routes/health-probe";
51import healthDashboardRoutes from "./routes/health";
2316be6Claude52import statusRoutes from "./routes/status";
b1be050CC LABS App53import adminStatusRoutes from "./routes/admin-status";
80bed05Claude54import helpRoutes from "./routes/help";
e1fc7dbClaude55import changelogRoutes from "./routes/changelog";
e0e4219Claude56import docsRoutes from "./routes/docs";
b0148e9Claude57import marketingRoutes from "./routes/marketing";
5f2e749Claude58import pricingRoutes from "./routes/pricing";
9f29b65Claude59import enterpriseRoutes from "./routes/enterprise";
5618f9aClaude60import seoRoutes from "./routes/seo";
05cdb85Claude61import versionRoutes from "./routes/version";
f295f78Dictation App62import { platformStatus } from "./routes/platform-status";
52ad8b1Claude63import publicStatsRoutes from "./routes/public-stats";
64import demoRoutes from "./routes/demo";
16b325cClaude65import insightRoutes from "./routes/insights";
8d1483cClaude66import doraRoutes from "./routes/dora";
f1ab587Claude67import dashboardRoutes from "./routes/dashboard";
36b4cbdClaude68import legalRoutes from "./routes/legal";
4b66018Claude69import legalDmcaRoutes from "./routes/legal/dmca";
70import legalTermsRoutes from "./routes/legal/terms";
71import legalPrivacyRoutes from "./routes/legal/privacy";
72import legalAcceptableUseRoutes from "./routes/legal/acceptable-use";
bdbd0deClaude73import importRoutes from "./routes/import";
14c3cc8Claude74import importBulkRoutes from "./routes/import-bulk";
f390cfaCC LABS App75import importSecretsRoutes from "./routes/import-secrets";
bb2dea9Claude76import actionsImporterRoutes from "./routes/actions-importer";
14c3cc8Claude77import migrationRoutes from "./routes/migrations";
9a8b8deClaude78import migrateRoutes from "./routes/migrate";
14c3cc8Claude79import specsRoutes from "./routes/specs";
23d0abfClaude80import refactorRoutes from "./routes/refactors";
79136bbClaude81import webRoutes from "./routes/web";
0316dbbClaude82import hookRoutes from "./routes/hooks";
83import eventsRoutes from "./routes/events";
84import passkeyRoutes from "./routes/passkeys";
85import oauthRoutes from "./routes/oauth";
86import developerAppsRoutes from "./routes/developer-apps";
87import themeRoutes from "./routes/theme";
88import auditRoutes from "./routes/audit";
89import reactionRoutes from "./routes/reactions";
90import savedReplyRoutes from "./routes/saved-replies";
91import deploymentRoutes from "./routes/deployments";
92import orgRoutes from "./routes/orgs";
93import notificationRoutes from "./routes/notifications";
94import onboardingRoutes from "./routes/onboarding";
95import adminRoutes from "./routes/admin";
7293c67Claude96import adminDeletionsRoutes from "./routes/admin-deletions";
97import adminStripeRoutes from "./routes/admin-stripe";
f764c07Claude98import adminDeploysRoutes from "./routes/admin-deploys";
99import adminDeploysPageRoutes from "./routes/admin-deploys-page";
783dd46Claude100import adminServerTargetsRoutes from "./routes/admin-server-targets";
9aaa128Claude101import deployTargetsRoutes from "./routes/deploy-targets";
90c7531Claude102import claudeWebRoutes from "./routes/claude-web";
9dd96b9Test User103import adminOpsRoutes from "./routes/admin-ops";
f2c00b4CC LABS App104import adminSelfHostRoutes from "./routes/admin-self-host";
826eccfTest User105import adminDiagnoseRoutes from "./routes/admin-diagnose";
509c376Claude106import adminIntegrationsRoutes from "./routes/admin-integrations";
79ed944Claude107import adminAdvancementRoutes from "./routes/admin-advancement";
ba9e143Claude108import adminSecurityRoutes from "./routes/admin-security";
109import settingsSessionsRoutes from "./routes/settings-sessions";
0316dbbClaude110import advisoriesRoutes from "./routes/advisories";
111import aiChangelogRoutes from "./routes/ai-changelog";
0a69faaClaude112import explainRoutes from "./routes/explain";
0316dbbClaude113import aiExplainRoutes from "./routes/ai-explain";
114import aiTestsRoutes from "./routes/ai-tests";
115import askRoutes from "./routes/ask";
38d31d3Claude116import repoChatRoutes from "./routes/repo-chat";
ee7e577Claude117import personalChatRoutes from "./routes/personal-chat";
0316dbbClaude118import billingRoutes from "./routes/billing";
8809b87Claude119import billingUsageRoutes from "./routes/billing-usage";
6778ad2Claude120import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude121import codeScanningRoutes from "./routes/code-scanning";
da3fc18Claude122import securityRoutes from "./routes/security";
0316dbbClaude123import commitStatusesRoutes from "./routes/commit-statuses";
124import copilotRoutes from "./routes/copilot";
125import depUpdaterRoutes from "./routes/dep-updater";
126import depsRoutes from "./routes/deps";
127import discussionsRoutes from "./routes/discussions";
128import environmentsRoutes from "./routes/environments";
4bbacbeClaude129import previewsRoutes from "./routes/previews";
79ed944Claude130import docsTrackingRoutes from "./routes/docs-tracking";
0316dbbClaude131import followsRoutes from "./routes/follows";
132import gatesRoutes from "./routes/gates";
133import gistsRoutes from "./routes/gists";
134import graphqlRoutes from "./routes/graphql";
2c2163eClaude135import mcpRoutes from "./routes/mcp";
0316dbbClaude136import marketplaceRoutes from "./routes/marketplace";
5ca514aClaude137import marketplaceAgentsRoutes from "./routes/marketplace-agents";
0316dbbClaude138import mergeQueueRoutes from "./routes/merge-queue";
139import mirrorsRoutes from "./routes/mirrors";
140import orgInsightsRoutes from "./routes/org-insights";
141import packagesRoutes from "./routes/packages";
142import packagesApiRoutes from "./routes/packages-api";
845fd8aClaude143import ociRegistryRoutes from "./routes/oci-registry";
0316dbbClaude144import pagesRoutes from "./routes/pages";
145import projectsRoutes from "./routes/projects";
146import protectedTagsRoutes from "./routes/protected-tags";
147import pwaRoutes from "./routes/pwa";
46d6165Claude148import installRoutes from "./routes/install";
cd4f63bTest User149import dxtRoutes from "./routes/dxt";
662ce86Claude150import connectClaudeRoutes from "./routes/connect-claude";
ebbb527Claude151import claudeDeployRoutes from "./routes/claude-deploy";
f5b9ef5Claude152import claudeIntegration from "./routes/claude-integration";
153import connectRoutes from "./routes/connect";
05ab9b1Claude154import pushWatchRoutes from "./routes/push-watch";
155import orgSecretsRoutes from "./routes/org-secrets";
0316dbbClaude156import releasesRoutes from "./routes/releases";
157import requiredChecksRoutes from "./routes/required-checks";
158import rulesetsRoutes from "./routes/rulesets";
159import searchRoutes from "./routes/search";
160import semanticSearchRoutes from "./routes/semantic-search";
161import signingKeysRoutes from "./routes/signing-keys";
162import sponsorsRoutes from "./routes/sponsors";
163import ssoRoutes from "./routes/sso";
46d6165Claude164import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude165import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude166import symbolsRoutes from "./routes/symbols";
167import templatesRoutes from "./routes/templates";
168import trafficRoutes from "./routes/traffic";
169import wikisRoutes from "./routes/wikis";
170import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude171import workflowArtifactsRoutes from "./routes/workflow-artifacts";
172import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude173import sleepModeRoutes from "./routes/sleep-mode";
56801e1Claude174import standupRoutes from "./routes/standups";
52ad8b1Claude175import vsGithubRoutes from "./routes/vs-github";
45f3b73Claude176import voiceRoutes from "./routes/voice-to-pr";
3122762Claude177import blogRoutes from "./routes/blog";
cd4f63bTest User178import playgroundRoutes from "./routes/playground";
a2b3e99Claude179import crossRepoSearchRoutes from "./routes/cross-repo-search";
180import pushNotifRoutes from "./routes/push-notifications";
9fbe6cdClaude181import velocityRoutes from "./routes/velocity";
182import { staleBranchRoutes } from "./routes/stale-branches";
22f43f3Claude183import pulseRoutes from "./routes/pulse";
74d8c4dClaude184import healthScoreRoutes from "./routes/health-score";
185import hotFilesRoutes from "./routes/hot-files";
adf5e18Claude186import developerProgramRoutes from "./routes/developer-program";
891efbeClaude187import shareRoutes from "./routes/share";
59b6fb2Claude188import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
189import { csrfToken, csrfProtect } from "./middleware/csrf";
f5b9ef5Claude190import { noCache } from "./middleware/no-cache";
79136bbClaude191
2316901Claude192import type { AuthEnv } from "./middleware/auth";
bf19c50Test User193import { softAuth } from "./middleware/auth";
2316901Claude194
195const app = new Hono<AuthEnv>();
79136bbClaude196
3ef4c9dClaude197// Request context (request ID, start time) runs before everything else
198app.use("*", requestContext);
05b973eClaude199// Middleware — compression first (wraps all responses)
200app.use("*", compress());
f1ffd50Claude201
202// ETag middleware — returns 304 Not Modified on unchanged responses.
203// Saves ~95% bandwidth on repeat visits. Skipped on git protocol +
204// SSE + the API surface where it would interfere with streaming.
205app.use("*", async (c, next) => {
206 const p = c.req.path;
207 if (
208 p.includes(".git/") ||
209 p.startsWith("/live-events") ||
210 p.startsWith("/api/events/deploy") ||
3c03977Claude211 p.startsWith("/admin/status") ||
212 // PR live co-editing SSE stream — never etag streaming responses.
213 /^\/api\/v2\/pulls\/[^/]+\/live(\/|$)/.test(p)
f1ffd50Claude214 ) {
215 return next();
216 }
217 return etag()(c, next);
218});
219
220// Cache-Control middleware — sets sensible defaults on public, anonymous
221// requests. Crontech (when wired as our edge layer) and downstream
222// browsers will honor these. Auth'd users get private,no-store
223// automatically — we never cache responses tied to a session.
224app.use("*", async (c, next) => {
225 await next();
226 // Don't overwrite explicit headers set by route handlers — BUT the
227 // ETag middleware unconditionally sets "private, no-cache, must-
228 // revalidate" so we have to treat that specific value as "no
229 // policy chosen yet" and apply ours. Any route that explicitly set
230 // a different cache-control wins.
231 const existing = c.res.headers.get("cache-control");
232 const etagDefault =
233 existing === "private, no-cache, must-revalidate" ||
234 existing === "no-cache";
235 if (existing && !etagDefault) return;
236 // Anything past auth: private + no-store (avoid leaking session
237 // content into shared caches). softAuth runs before this on the
238 // request, but the response side is what we're stamping.
239 const hasSession = c.req.header("cookie")?.includes("session=") ?? false;
240 const p = c.req.path;
241 // Always private for known-authed paths regardless of cookie.
242 if (
243 p.startsWith("/admin") ||
244 p.startsWith("/settings") ||
245 p.startsWith("/dashboard") ||
246 p.startsWith("/notifications") ||
247 p.startsWith("/connect/") ||
248 hasSession
249 ) {
250 c.res.headers.set("cache-control", "private, no-store");
251 return;
252 }
253 // Public marketing surfaces — short edge cache, longer browser cache,
254 // stale-while-revalidate so the user never waits on a stale fetch.
255 const isMarketing =
256 p === "/" ||
257 p === "/features" ||
258 p === "/pricing" ||
259 p === "/about" ||
260 p === "/vs-github" ||
261 p === "/explore" ||
262 p === "/help" ||
263 p === "/changelog" ||
9f29b65Claude264 p === "/enterprise" ||
f1ffd50Claude265 p.startsWith("/legal/") ||
266 p === "/terms" ||
267 p === "/privacy" ||
268 p === "/acceptable-use" ||
269 p.startsWith("/docs/");
270 if (isMarketing) {
271 c.res.headers.set(
272 "cache-control",
273 "public, max-age=60, s-maxage=300, stale-while-revalidate=86400"
274 );
275 return;
276 }
277 // Public repo browse pages — cache aggressively. Edge invalidates
278 // on push via the post-receive hook (future Crontech surge purge).
279 if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") {
280 c.res.headers.set(
281 "cache-control",
282 "public, max-age=30, s-maxage=120, stale-while-revalidate=600"
283 );
284 return;
285 }
286 // Default: don't cache anything we haven't explicitly opted in.
287 c.res.headers.set("cache-control", "private, no-store");
288});
05b973eClaude289// Logger only on non-git routes to avoid overhead on clone/push
290app.use("*", async (c, next) => {
291 if (c.req.path.includes(".git/")) return next();
292 return logger()(c, next);
293});
79136bbClaude294app.use("/api/*", cors());
bf19c50Test User295// Global softAuth — populates c.get("user") for every downstream middleware
296// + route. This was previously per-route, which meant rate-limit middleware
297// (and anything else inspecting auth state) always saw a null user. Keep
298// individual routes free to add requireAuth on top for hard gating; this
299// just establishes the user object cheaply.
300app.use("*", softAuth);
290ea77Claude301
36cc17aClaude302// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude303// pre-redesign markup. JSON / static assets keep their own cache rules; only
304// text/html responses get the no-cache stamp. Without this, every push to
305// main left users staring at cached 80s-looking pages from before the design
306// landed.
36cc17aClaude307//
308// We deliberately use `private, no-cache, must-revalidate` rather than
309// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
310// which makes every Back/Forward press a cold server round-trip — that
311// contributed to the "every nav feels like a fresh login" UX complaint.
312// `no-cache` still revalidates on direct fetch but lets bfcache hold the
313// page in memory between navigations.
290ea77Claude314app.use("*", async (c, next) => {
315 await next();
316 const ct = c.res.headers.get("content-type") || "";
317 if (ct.startsWith("text/html")) {
36cc17aClaude318 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude319 }
320});
826eccfTest User321// Rate-limit API + auth endpoints.
322//
a41e675Test User323// `/api/*`: 1000/min per IP — generous so an admin clicking around the
324// operator console (or a CDN/proxy concentrating multiple users behind one
325// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
326// rate limits below, not this one.
327//
328// `authedMultiplier` is set but only fires when an upstream middleware has
329// already populated c.get("user") — most app.use() chains apply softAuth
330// per-route, so the multiplier is best-effort. Keep the anonymous base
331// high enough that humans never feel it.
332//
333// Skip-paths: dashboard plumbing endpoints that the layout polls on a
334// fixed cadence and that we don't want consuming any bucket:
335// /api/version — layout polls every 15s
826eccfTest User336// /api/notifications/count — nav bell unread-count fetcher
337// /pwa/vapid-public-key — fetched once per push-notification opt-in
338app.use(
339 "/api/*",
a41e675Test User340 rateLimit(1000, 60_000, "api", {
826eccfTest User341 authedMultiplier: 4,
342 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
343 })
344);
0316dbbClaude345app.use("/login", rateLimit(20, 60_000, "login"));
346app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude347// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
348app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User349// BLOCK Q2 — throttle magic-link sign-in for the same reason.
350app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude351
59b6fb2Claude352// CSRF protection — set token on all requests, validate on mutations
353app.use("*", csrfToken);
354app.use("*", csrfProtect);
355
45e31d0Claude356// Rate limit auth routes
357app.use("/login", authRateLimit);
358app.use("/register", authRateLimit);
359
59b6fb2Claude360// Rate limit git operations
361app.use("/:owner/:repo.git/*", gitRateLimit);
362
363// Rate limit search
364app.use("/:owner/:repo/search", searchRateLimit);
365app.use("/explore", searchRateLimit);
79136bbClaude366
f5b9ef5Claude367// No-cache for HTML — ensures browsers and proxies never serve stale pages.
368// The middleware only stamps text/html responses so static assets keep
369// their own cache policies unchanged.
370app.use("*", noCache);
371
79136bbClaude372// Git Smart HTTP protocol routes (must be before web routes)
373app.route("/", gitRoutes);
374
45e31d0Claude375// REST API v1 (legacy)
79136bbClaude376app.route("/", apiRoutes);
377
52ad8b1Claude378// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
379// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
380// router's catch-shape, and BEFORE adminRoutes so the live /demo page
381// wins over the legacy /demo redirect in src/routes/admin.tsx.
382app.route("/", demoRoutes);
383
0316dbbClaude384// REST API v2 (basePath /api/v2)
385app.route("/", apiV2Routes);
386
e75eddcClaude387// Agent multiplayer v1 — /api/v2/agents/* (sessions, leases, usage).
388// Mounted alongside apiV2Routes (its own basePath, no path conflict).
389app.route("/", agentsRoutes);
390
ef3fd93Claude391// Multi-agent pipeline UI — /:owner/:repo/agents (list, new, live view).
392// Must be before webRoutes (the catch-all) so the /agents sub-paths are
393// resolved before the generic tree/blob route takes over.
394app.route("/", agentPipelinesRoutes);
395
ad6d4adClaude396// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
397app.route("/", hookRoutes);
21f8dbdClaude398app.route("/api/events", eventsRoutes);
ad6d4adClaude399
45e31d0Claude400// API documentation
401app.route("/", apiDocsRoutes);
4a80519Claude402app.route("/", buildAgentSpecRoutes);
a6ff0f2Claude403// PR command center — global PR dashboard with AI/GateTest/auto-merge signal
404app.route("/", pullsDashboardRoutes);
e9aa4d8Claude405// Issue command center — global issue dashboard with AI-triage + autopilot signal
406app.route("/", issuesDashboardRoutes);
407// Personal activity timeline — every event across the user's repos, with
408// AI-driven events surfaced separately (the Gluecron differentiator).
409app.route("/", activityRoutes);
410// Unified inbox — mentions + review requests + CI failures + AI events in one timeline
411app.route("/", inboxRoutes);
56801e1Claude412// AI standup feed — daily / weekly Claude-generated team brief
413app.route("/", standupRoutes);
79136bbClaude414
415// Auth routes (register, login, logout)
416app.route("/", authRoutes);
417
c63b860Claude418// BLOCK P1 — Password reset (forgot-password + reset-password)
419app.route("/", passwordResetRoutes);
420
421// BLOCK P2 — Email verification (verify-email + resend)
422app.route("/", emailVerificationRoutes);
423
cd4f63bTest User424// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
425app.route("/", magicLinkRoutes);
426
79136bbClaude427// Settings routes (profile, SSH keys)
428app.route("/", settingsRoutes);
429
ba9e143Claude430// Session management (SOC 2 CC6.1 — /settings/sessions)
431app.route("/", settingsSessionsRoutes);
432
7298a17Claude433// 2FA / TOTP settings (Block B4)
434app.route("/", settings2faRoutes);
435
e75eddcClaude436// Agent multiplayer — /settings/agents management UI
437app.route("/", settingsAgentsRoutes);
438
1d4ff60Claude439// Chat integrations — Slack / Discord / Teams (/settings/integrations
440// + /api/v2/integrations/{slack,discord}/*). See src/lib/chat-bot.ts.
441app.route("/", settingsIntegrationsRoutes);
442app.route("/", integrationsChatRoutes);
443
2df1f8cClaude444// WebAuthn / passkey routes (Block B5)
445app.route("/", passkeyRoutes);
446
058d752Claude447// OAuth 2.0 provider (Block B6)
448app.route("/", oauthRoutes);
449app.route("/", developerAppsRoutes);
450
6fc53bdClaude451// Theme toggle (dark/light cookie)
452app.route("/", themeRoutes);
453
454// Audit log UI
455app.route("/", auditRoutes);
456
457// Reactions API (issues, PRs, comments)
458app.route("/", reactionRoutes);
459
24cf2caClaude460// Saved replies (per-user canned comment templates)
461app.route("/", savedReplyRoutes);
462
463// Environments + deployment history UI
464app.route("/", deploymentRoutes);
465
6563f0aClaude466// Organizations + teams (Block B1)
467app.route("/", orgRoutes);
468
c81ab7aClaude469// API tokens
470app.route("/", tokenRoutes);
471
59b6fb2Claude472// Notifications
3ef4c9dClaude473app.route("/", notificationRoutes);
474
79136bbClaude475// Repo settings (description, visibility, delete)
476app.route("/", repoSettings);
477
23d1a81Claude478// Repo collaborators (add/list/remove)
479app.route("/", collaboratorRoutes);
480
04f6b7fClaude481// Team-based repo collaborators (invite a whole team)
482app.route("/", teamCollaboratorRoutes);
483
484// Collaborator invite accept flow (token-based)
485app.route("/", invitesRoutes);
486
487// Real-time SSE endpoint (topic-based live updates)
488app.route("/", liveEventsRoutes);
489
3c03977Claude490// PR live co-editing — presence + cursors + content sync via SSE.
491app.route("/", prLiveRoutes);
492
c81ab7aClaude493// Webhooks management
494app.route("/", webhookRoutes);
495
79136bbClaude496// Compare view (branch diffs)
497app.route("/", compareRoutes);
498
499// Issue tracker
500app.route("/", issueRoutes);
501
cb5a796Claude502// Comment moderation queue — owner-only `/:owner/:repo/comments/pending`
503// + per-row approve/reject/spam actions. Mounted before `pullRoutes` so
504// the `/:owner/:repo/comments/*` paths resolve before the broader PR
505// patterns kick in.
506app.route("/", commentModerationRoutes);
507
0074234Claude508// Pull requests
509app.route("/", pullRoutes);
3033f70Claude510
511// /stage PR preview — serve built static files from .stage-previews/{jobId}/
512// Registered immediately after pullRoutes so the path `/preview/:id/*` is
513// specific enough to never clash with repo browse routes (`/:owner/:repo/*`).
514app.get("/preview/:stageJobId/*", async (c) => {
515 const { stageJobId } = c.req.param();
516 // Validate job ID format (UUID)
517 if (!/^[0-9a-f-]{32,}$/i.test(stageJobId)) {
518 return c.text("Not found", 404);
519 }
520 const { getPreviewDir, isPreviewExpired } = await import("./lib/pr-stage");
521 if (isPreviewExpired(stageJobId)) {
522 return c.html(
523 "<html><body style='font-family:sans-serif;padding:40px;color:#888'>" +
524 "<h2>Preview expired</h2><p>This stage preview has expired (48h TTL). " +
525 "Comment <code>/stage</code> on the PR to redeploy.</p></body></html>",
526 410
527 );
528 }
529 const { join } = await import("path");
530 const previewDir = getPreviewDir(stageJobId);
531 // Extract the wildcard path after /preview/:id/
532 const rawPath = c.req.path.replace(/^\/preview\/[^/]+/, "") || "/";
533 const filePath = rawPath === "/" || rawPath === "" ? "/index.html" : rawPath;
534 const fullPath = join(previewDir, filePath);
535 const file = Bun.file(fullPath);
536 if (!(await file.exists())) {
537 // Try index.html fallback (SPA behaviour)
538 const indexFile = Bun.file(join(previewDir, "index.html"));
539 if (await indexFile.exists()) {
540 const html = await indexFile.text();
541 return c.html(html);
542 }
543 return c.text("Not found", 404);
544 }
545 const content = await file.arrayBuffer();
546 const ext = fullPath.split(".").pop()?.toLowerCase() ?? "";
547 const contentTypeMap: Record<string, string> = {
548 html: "text/html; charset=utf-8",
549 htm: "text/html; charset=utf-8",
550 css: "text/css; charset=utf-8",
551 js: "application/javascript; charset=utf-8",
552 mjs: "application/javascript; charset=utf-8",
553 json: "application/json; charset=utf-8",
554 png: "image/png",
555 jpg: "image/jpeg",
556 jpeg: "image/jpeg",
557 gif: "image/gif",
558 svg: "image/svg+xml",
559 ico: "image/x-icon",
560 webp: "image/webp",
561 woff: "font/woff",
562 woff2: "font/woff2",
563 ttf: "font/ttf",
564 txt: "text/plain; charset=utf-8",
565 xml: "application/xml",
566 webmanifest: "application/manifest+json",
567 };
568 const ct = contentTypeMap[ext] ?? "application/octet-stream";
569 return c.body(content, 200, {
570 "content-type": ct,
571 "cache-control": "public, max-age=300",
572 "x-stage-job-id": stageJobId,
573 });
574});
575
79ed944Claude576// PR sandboxes — runnable per-PR environments. Migration 0067.
577app.route("/", prSandboxRoutes);
0074234Claude578
9b3a183Claude579// Cloud dev environments — hosted VS Code in the browser. Migration 0072.
580app.route("/", devEnvRoutes);
581
c81ab7aClaude582// Fork
583app.route("/", forkRoutes);
584
0074234Claude585// Web file editor
586app.route("/", editorRoutes);
587
6f2809fClaude588// AI editor API routes (inline suggestions, explain, fix)
589app.route("/", aiEditorRoutes);
590
43de941Claude591// Contributors
592app.route("/", contributorRoutes);
593
699e5c7Claude594// Health liveness + metrics endpoints
2c34075Claude595app.route("/", healthRoutes);
596
f295f78Dictation App597// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
598app.route("/api/platform-status", platformStatus);
599
52ad8b1Claude600// Block L4 — Public stats counters (powers landing-page social proof)
601app.route("/", publicStatsRoutes);
602
603// Block L3 — Live /demo page + /api/v2/demo/* endpoints
604app.route("/", demoRoutes);
605
2316be6Claude606// Public /status — human-readable platform health page
607app.route("/", statusRoutes);
608
b1be050CC LABS App609// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
610// Mounted near the public status route so the two surfaces are visible
611// side-by-side; routes are gated by isSiteAdmin internally.
612app.route("/", adminStatusRoutes);
613
80bed05Claude614// /help — quickstart + API cheatsheet
615app.route("/", helpRoutes);
616
e0e4219Claude617// /docs — expanded documentation site (getting started, workflow YAML, MCP, API, agents)
618app.route("/", docsRoutes);
619
5f2e749Claude620// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
621// so the new editorial pricing layout wins the route; the legacy marketing
622// pricing remains as a safety net but is shadowed at the router.
623app.route("/", pricingRoutes);
624
e1fc7dbClaude625// /changelog — manually curated platform release history
626app.route("/", changelogRoutes);
627
9f29b65Claude628// Enterprise sales page + contact form lead capture.
629app.route("/", enterpriseRoutes);
630
b0148e9Claude631// /pricing, /features, /about — marketing surface
632app.route("/", marketingRoutes);
633
adf5e18Claude634// /developer-program — partner + marketplace revenue-share page
635app.route("/", developerProgramRoutes);
636
5618f9aClaude637// SEO: robots.txt + sitemap.xml
638app.route("/", seoRoutes);
639
05cdb85Claude640// /api/version — live build SHA + uptime; client poller uses this to
641// surface 'New version available — reload' banners on deploy.
642app.route("/", versionRoutes);
643
699e5c7Claude644// Health dashboard (per-repo health page)
645app.route("/", healthDashboardRoutes);
646
9dd96b9Test User647// Block R1 — site-admin operations console. MUST be mounted BEFORE
648// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
649// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
650app.route("/", adminOpsRoutes);
f2c00b4CC LABS App651// BLOCK W — Self-host status + bootstrap dashboard.
652app.route("/", adminSelfHostRoutes);
826eccfTest User653// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
654app.route("/", adminDiagnoseRoutes);
9dd96b9Test User655
16b325cClaude656// Insights (time-travel, dependencies, rollback)
657app.route("/", insightRoutes);
658
8d1483cClaude659// DORA metrics page (/:owner/:repo/insights/dora)
660app.route("/", doraRoutes);
661
f1ab587Claude662// Command center dashboard
663app.route("/", dashboardRoutes);
664
36b4cbdClaude665// Legal pages (terms, privacy, AUP)
666app.route("/", legalRoutes);
4b66018Claude667// Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}.
668// The main `legal.tsx` serves the short canonical paths (/terms, /privacy,
669// /acceptable-use); these are the formal versions that the legal pages
670// internally link to each other.
671app.route("/", legalTermsRoutes);
672app.route("/", legalPrivacyRoutes);
673app.route("/", legalAcceptableUseRoutes);
674app.route("/", legalDmcaRoutes);
36b4cbdClaude675
bdbd0deClaude676// GitHub import / migration
677app.route("/", importRoutes);
14c3cc8Claude678app.route("/", importBulkRoutes);
f390cfaCC LABS App679app.route("/", importSecretsRoutes);
bb2dea9Claude680// GitHub Actions → Gluecron gates.yml importer (stateless converter)
681app.route("/", actionsImporterRoutes);
14c3cc8Claude682app.route("/", migrationRoutes);
9a8b8deClaude683// GitHub Org Migration Wizard — live progress bulk importer
684app.route("/", migrateRoutes);
14c3cc8Claude685
686// Spec-to-PR (experimental AI-generated draft PRs)
687app.route("/", specsRoutes);
23d0abfClaude688app.route("/", refactorRoutes);
bdbd0deClaude689
c81ab7aClaude690// Explore page
691app.route("/", exploreRoutes);
692
59b6fb2Claude693// Onboarding
694app.route("/", onboardingRoutes);
695
0316dbbClaude696// Admin + feature routes
697app.route("/", adminRoutes);
7293c67Claude698app.route("/", adminDeletionsRoutes);
699app.route("/", adminStripeRoutes);
ba9e143Claude700
701// SOC 2 security dashboard + readiness checklist (/admin/security, /admin/soc2)
702app.route("/", adminSecurityRoutes);
509c376Claude703app.route("/", adminIntegrationsRoutes);
79ed944Claude704app.route("/", adminAdvancementRoutes);
f764c07Claude705app.route("/", adminDeploysRoutes);
706app.route("/", adminDeploysPageRoutes);
783dd46Claude707app.route("/", adminServerTargetsRoutes);
9aaa128Claude708app.route("/", deployTargetsRoutes);
90c7531Claude709app.route("/", claudeWebRoutes);
9dd96b9Test User710// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude711app.route("/", advisoriesRoutes);
712app.route("/", aiChangelogRoutes);
0a69faaClaude713// "Explain This Repo" — rich structured AI analysis dashboard (mounted before
714// the simpler aiExplainRoutes so the new routes win on /:owner/:repo/explain).
715app.route("/", explainRoutes);
0316dbbClaude716app.route("/", aiExplainRoutes);
717app.route("/", aiTestsRoutes);
718app.route("/", askRoutes);
38d31d3Claude719app.route("/", repoChatRoutes);
ee7e577Claude720// Personal cross-repo chat — `/chat` (user-scoped). Mounted alongside
721// repoChatRoutes so the two surfaces share the catch-all priority.
722app.route("/", personalChatRoutes);
0316dbbClaude723app.route("/", billingRoutes);
8809b87Claude724app.route("/", billingUsageRoutes);
6778ad2Claude725app.route("/", stripeWebhookRoutes);
0316dbbClaude726app.route("/", codeScanningRoutes);
da3fc18Claude727// Dependency CVE scanner findings page — /:owner/:repo/security/vulnerabilities
728app.route("/", securityRoutes);
0316dbbClaude729app.route("/", commitStatusesRoutes);
730app.route("/", copilotRoutes);
731app.route("/", depUpdaterRoutes);
732app.route("/", depsRoutes);
733app.route("/", discussionsRoutes);
734app.route("/", environmentsRoutes);
4bbacbeClaude735app.route("/", previewsRoutes);
79ed944Claude736app.route("/", docsTrackingRoutes);
0316dbbClaude737app.route("/", followsRoutes);
738app.route("/", gatesRoutes);
739app.route("/", gistsRoutes);
740app.route("/", graphqlRoutes);
2c2163eClaude741app.route("/", mcpRoutes);
0316dbbClaude742app.route("/", marketplaceRoutes);
5ca514aClaude743app.route("/", marketplaceAgentsRoutes);
0316dbbClaude744app.route("/", mergeQueueRoutes);
745app.route("/", mirrorsRoutes);
746app.route("/", orgInsightsRoutes);
747app.route("/", packagesRoutes);
748app.route("/", packagesApiRoutes);
845fd8aClaude749// OCI / Docker container registry — /v2/* (OCI Distribution Spec v1.0)
750app.route("/", ociRegistryRoutes);
0316dbbClaude751app.route("/", pagesRoutes);
752app.route("/", projectsRoutes);
753app.route("/", protectedTagsRoutes);
754app.route("/", pwaRoutes);
46d6165Claude755app.route("/", installRoutes);
cd4f63bTest User756// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
757app.route("/", dxtRoutes);
662ce86Claude758// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
759// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
760app.route("/", connectClaudeRoutes);
f5b9ef5Claude761// Claude Code Integration Receiver — /api/claude/connect + /api/claude/session.
762app.route("/", claudeIntegration);
763// Connect guide — public onboarding page (/connect/claude-guide).
764app.route("/", connectRoutes);
05ab9b1Claude765// Push Watch — per-commit live status (gates + deploy + latency) at /:owner/:repo/push/:sha
766app.route("/", pushWatchRoutes);
767// Org Secrets Manager — BLOCK M2 — /orgs/:slug/settings/secrets
768app.route("/", orgSecretsRoutes);
a2b3e99Claude769// Cross-repo code search — BLOCK M3 — /search/code + /api/search/code
770app.route("/", crossRepoSearchRoutes);
771// Browser push notifications — BLOCK M4 — /settings/notifications/push + /api/push/*
772app.route("/", pushNotifRoutes);
9fbe6cdClaude773// Developer Velocity Dashboard — BLOCK M9 — /:owner/:repo/insights/velocity
774app.route("/", velocityRoutes);
775// Stale Branch Cleanup — BLOCK M10 — /:owner/:repo/branches/stale
776app.route("/", staleBranchRoutes);
22f43f3Claude777// Repository Pulse — BLOCK M12 — /:owner/:repo/pulse
778app.route("/", pulseRoutes);
74d8c4dClaude779// Repository Health Score — BLOCK M14 — /:owner/:repo/insights/health
780app.route("/", healthScoreRoutes);
781// Hot Files Heatmap — BLOCK M16 — /:owner/:repo/insights/hotfiles
782app.route("/", hotFilesRoutes);
ebbb527Claude783// Hosted Claude tool-use loops — paste loop, get endpoint, billing meter.
784// See src/routes/claude-deploy.tsx + src/lib/hosted-claude-loop.ts.
785app.route("/", claudeDeployRoutes);
0316dbbClaude786app.route("/", releasesRoutes);
787app.route("/", requiredChecksRoutes);
788app.route("/", rulesetsRoutes);
789app.route("/", searchRoutes);
790app.route("/", semanticSearchRoutes);
791app.route("/", signingKeysRoutes);
792app.route("/", sponsorsRoutes);
793app.route("/", ssoRoutes);
46d6165Claude794app.route("/", githubOauthRoutes);
582cdacClaude795app.route("/", googleOauthRoutes);
0316dbbClaude796app.route("/", symbolsRoutes);
797app.route("/", templatesRoutes);
798app.route("/", trafficRoutes);
799app.route("/", wikisRoutes);
800app.route("/", workflowsRoutes);
5ff9cc2Claude801app.route("/", workflowArtifactsRoutes);
802app.route("/", workflowSecretsRoutes);
46d6165Claude803app.route("/", sleepModeRoutes);
52ad8b1Claude804app.route("/", vsGithubRoutes);
0316dbbClaude805
45f3b73Claude806// Voice-to-PR — phone-first dictation → spec or issue
807app.route("/", voiceRoutes);
808
3122762Claude809// Blog / Devlog — public posts, no DB
810app.route("/", blogRoutes);
811
cd4f63bTest User812// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
813// before the web catch-all so the bare `/play` literal wins over the
814// `/:owner` user-profile route.
815app.route("/", playgroundRoutes);
816
891efbeClaude817// Shareable AI hours-saved OG image card + landing page.
818// /share/hours-saved?user=:username → 1200×630 SVG (og:image)
819// /share/:username → HTML page with og:image meta + Twitter share
820// Mounted BEFORE webRoutes so /share/* doesn't fall through to the /:owner profile route.
821app.route("/", shareRoutes);
822
79136bbClaude823// Web UI (catch-all, must be last)
824app.route("/", webRoutes);
825
c63b860Claude826// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
827// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude828app.notFound((c) => {
36cc17aClaude829 const user = c.get("user") ?? null;
79136bbClaude830 return c.html(
c63b860Claude831 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude832 404
833 );
834});
835
c63b860Claude836// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
837// view. Trace block only shown outside production.
79136bbClaude838app.onError((err, c) => {
80bed05Claude839 reportError(err, {
840 requestId: c.get("requestId"),
841 path: c.req.path,
842 method: c.req.method,
843 });
c63b860Claude844 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
845 // back to the context value set by request-context middleware.
846 const requestId =
847 c.req.header("x-request-id") ||
848 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude849 const user = c.get("user") ?? null;
c63b860Claude850 const trace =
851 process.env.NODE_ENV !== "production" && err && err.message
852 ? err.message
853 : undefined;
79136bbClaude854 return c.html(
c63b860Claude855 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude856 500
857 );
858});
859
860export default app;