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.tsxBlame630 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";
79136bbClaude34import compareRoutes from "./routes/compare";
0074234Claude35import pullRoutes from "./routes/pulls";
36import editorRoutes from "./routes/editor";
c81ab7aClaude37import forkRoutes from "./routes/fork";
38import webhookRoutes from "./routes/webhooks";
39import exploreRoutes from "./routes/explore";
40import tokenRoutes from "./routes/tokens";
43de941Claude41import contributorRoutes from "./routes/contributors";
699e5c7Claude42import healthRoutes from "./routes/health-probe";
43import healthDashboardRoutes from "./routes/health";
2316be6Claude44import statusRoutes from "./routes/status";
b1be050CC LABS App45import adminStatusRoutes from "./routes/admin-status";
80bed05Claude46import helpRoutes from "./routes/help";
b0148e9Claude47import marketingRoutes from "./routes/marketing";
5f2e749Claude48import pricingRoutes from "./routes/pricing";
5618f9aClaude49import seoRoutes from "./routes/seo";
05cdb85Claude50import versionRoutes from "./routes/version";
f295f78Dictation App51import { platformStatus } from "./routes/platform-status";
52ad8b1Claude52import publicStatsRoutes from "./routes/public-stats";
53import demoRoutes from "./routes/demo";
16b325cClaude54import insightRoutes from "./routes/insights";
f1ab587Claude55import dashboardRoutes from "./routes/dashboard";
36b4cbdClaude56import legalRoutes from "./routes/legal";
4b66018Claude57import legalDmcaRoutes from "./routes/legal/dmca";
58import legalTermsRoutes from "./routes/legal/terms";
59import legalPrivacyRoutes from "./routes/legal/privacy";
60import legalAcceptableUseRoutes from "./routes/legal/acceptable-use";
bdbd0deClaude61import importRoutes from "./routes/import";
14c3cc8Claude62import importBulkRoutes from "./routes/import-bulk";
f390cfaCC LABS App63import importSecretsRoutes from "./routes/import-secrets";
14c3cc8Claude64import migrationRoutes from "./routes/migrations";
65import specsRoutes from "./routes/specs";
79136bbClaude66import webRoutes from "./routes/web";
0316dbbClaude67import hookRoutes from "./routes/hooks";
68import eventsRoutes from "./routes/events";
69import passkeyRoutes from "./routes/passkeys";
70import oauthRoutes from "./routes/oauth";
71import developerAppsRoutes from "./routes/developer-apps";
72import themeRoutes from "./routes/theme";
73import auditRoutes from "./routes/audit";
74import reactionRoutes from "./routes/reactions";
75import savedReplyRoutes from "./routes/saved-replies";
76import deploymentRoutes from "./routes/deployments";
77import orgRoutes from "./routes/orgs";
78import notificationRoutes from "./routes/notifications";
79import onboardingRoutes from "./routes/onboarding";
80import adminRoutes from "./routes/admin";
f764c07Claude81import adminDeploysRoutes from "./routes/admin-deploys";
82import adminDeploysPageRoutes from "./routes/admin-deploys-page";
9dd96b9Test User83import adminOpsRoutes from "./routes/admin-ops";
f2c00b4CC LABS App84import adminSelfHostRoutes from "./routes/admin-self-host";
826eccfTest User85import adminDiagnoseRoutes from "./routes/admin-diagnose";
509c376Claude86import adminIntegrationsRoutes from "./routes/admin-integrations";
0316dbbClaude87import advisoriesRoutes from "./routes/advisories";
88import aiChangelogRoutes from "./routes/ai-changelog";
89import aiExplainRoutes from "./routes/ai-explain";
90import aiTestsRoutes from "./routes/ai-tests";
91import askRoutes from "./routes/ask";
92import billingRoutes from "./routes/billing";
6778ad2Claude93import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude94import codeScanningRoutes from "./routes/code-scanning";
95import commitStatusesRoutes from "./routes/commit-statuses";
96import copilotRoutes from "./routes/copilot";
97import depUpdaterRoutes from "./routes/dep-updater";
98import depsRoutes from "./routes/deps";
99import discussionsRoutes from "./routes/discussions";
100import environmentsRoutes from "./routes/environments";
101import followsRoutes from "./routes/follows";
102import gatesRoutes from "./routes/gates";
103import gistsRoutes from "./routes/gists";
104import graphqlRoutes from "./routes/graphql";
2c2163eClaude105import mcpRoutes from "./routes/mcp";
0316dbbClaude106import marketplaceRoutes from "./routes/marketplace";
107import mergeQueueRoutes from "./routes/merge-queue";
108import mirrorsRoutes from "./routes/mirrors";
109import orgInsightsRoutes from "./routes/org-insights";
110import packagesRoutes from "./routes/packages";
111import packagesApiRoutes from "./routes/packages-api";
112import pagesRoutes from "./routes/pages";
113import projectsRoutes from "./routes/projects";
114import protectedTagsRoutes from "./routes/protected-tags";
115import pwaRoutes from "./routes/pwa";
46d6165Claude116import installRoutes from "./routes/install";
cd4f63bTest User117import dxtRoutes from "./routes/dxt";
662ce86Claude118import connectClaudeRoutes from "./routes/connect-claude";
0316dbbClaude119import releasesRoutes from "./routes/releases";
120import requiredChecksRoutes from "./routes/required-checks";
121import rulesetsRoutes from "./routes/rulesets";
122import searchRoutes from "./routes/search";
123import semanticSearchRoutes from "./routes/semantic-search";
124import signingKeysRoutes from "./routes/signing-keys";
125import sponsorsRoutes from "./routes/sponsors";
126import ssoRoutes from "./routes/sso";
46d6165Claude127import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude128import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude129import symbolsRoutes from "./routes/symbols";
130import templatesRoutes from "./routes/templates";
131import trafficRoutes from "./routes/traffic";
132import wikisRoutes from "./routes/wikis";
133import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude134import workflowArtifactsRoutes from "./routes/workflow-artifacts";
135import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude136import sleepModeRoutes from "./routes/sleep-mode";
56801e1Claude137import standupRoutes from "./routes/standups";
52ad8b1Claude138import vsGithubRoutes from "./routes/vs-github";
45f3b73Claude139import voiceRoutes from "./routes/voice-to-pr";
cd4f63bTest User140import playgroundRoutes from "./routes/playground";
59b6fb2Claude141import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
142import { csrfToken, csrfProtect } from "./middleware/csrf";
79136bbClaude143
2316901Claude144import type { AuthEnv } from "./middleware/auth";
bf19c50Test User145import { softAuth } from "./middleware/auth";
2316901Claude146
147const app = new Hono<AuthEnv>();
79136bbClaude148
3ef4c9dClaude149// Request context (request ID, start time) runs before everything else
150app.use("*", requestContext);
05b973eClaude151// Middleware — compression first (wraps all responses)
152app.use("*", compress());
f1ffd50Claude153
154// ETag middleware — returns 304 Not Modified on unchanged responses.
155// Saves ~95% bandwidth on repeat visits. Skipped on git protocol +
156// SSE + the API surface where it would interfere with streaming.
157app.use("*", async (c, next) => {
158 const p = c.req.path;
159 if (
160 p.includes(".git/") ||
161 p.startsWith("/live-events") ||
162 p.startsWith("/api/events/deploy") ||
163 p.startsWith("/admin/status")
164 ) {
165 return next();
166 }
167 return etag()(c, next);
168});
169
170// Cache-Control middleware — sets sensible defaults on public, anonymous
171// requests. Crontech (when wired as our edge layer) and downstream
172// browsers will honor these. Auth'd users get private,no-store
173// automatically — we never cache responses tied to a session.
174app.use("*", async (c, next) => {
175 await next();
176 // Don't overwrite explicit headers set by route handlers — BUT the
177 // ETag middleware unconditionally sets "private, no-cache, must-
178 // revalidate" so we have to treat that specific value as "no
179 // policy chosen yet" and apply ours. Any route that explicitly set
180 // a different cache-control wins.
181 const existing = c.res.headers.get("cache-control");
182 const etagDefault =
183 existing === "private, no-cache, must-revalidate" ||
184 existing === "no-cache";
185 if (existing && !etagDefault) return;
186 // Anything past auth: private + no-store (avoid leaking session
187 // content into shared caches). softAuth runs before this on the
188 // request, but the response side is what we're stamping.
189 const hasSession = c.req.header("cookie")?.includes("session=") ?? false;
190 const p = c.req.path;
191 // Always private for known-authed paths regardless of cookie.
192 if (
193 p.startsWith("/admin") ||
194 p.startsWith("/settings") ||
195 p.startsWith("/dashboard") ||
196 p.startsWith("/notifications") ||
197 p.startsWith("/connect/") ||
198 hasSession
199 ) {
200 c.res.headers.set("cache-control", "private, no-store");
201 return;
202 }
203 // Public marketing surfaces — short edge cache, longer browser cache,
204 // stale-while-revalidate so the user never waits on a stale fetch.
205 const isMarketing =
206 p === "/" ||
207 p === "/features" ||
208 p === "/pricing" ||
209 p === "/about" ||
210 p === "/vs-github" ||
211 p === "/explore" ||
212 p === "/help" ||
213 p === "/changelog" ||
214 p.startsWith("/legal/") ||
215 p === "/terms" ||
216 p === "/privacy" ||
217 p === "/acceptable-use" ||
218 p.startsWith("/docs/");
219 if (isMarketing) {
220 c.res.headers.set(
221 "cache-control",
222 "public, max-age=60, s-maxage=300, stale-while-revalidate=86400"
223 );
224 return;
225 }
226 // Public repo browse pages — cache aggressively. Edge invalidates
227 // on push via the post-receive hook (future Crontech surge purge).
228 if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") {
229 c.res.headers.set(
230 "cache-control",
231 "public, max-age=30, s-maxage=120, stale-while-revalidate=600"
232 );
233 return;
234 }
235 // Default: don't cache anything we haven't explicitly opted in.
236 c.res.headers.set("cache-control", "private, no-store");
237});
05b973eClaude238// Logger only on non-git routes to avoid overhead on clone/push
239app.use("*", async (c, next) => {
240 if (c.req.path.includes(".git/")) return next();
241 return logger()(c, next);
242});
79136bbClaude243app.use("/api/*", cors());
bf19c50Test User244// Global softAuth — populates c.get("user") for every downstream middleware
245// + route. This was previously per-route, which meant rate-limit middleware
246// (and anything else inspecting auth state) always saw a null user. Keep
247// individual routes free to add requireAuth on top for hard gating; this
248// just establishes the user object cheaply.
249app.use("*", softAuth);
290ea77Claude250
36cc17aClaude251// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude252// pre-redesign markup. JSON / static assets keep their own cache rules; only
253// text/html responses get the no-cache stamp. Without this, every push to
254// main left users staring at cached 80s-looking pages from before the design
255// landed.
36cc17aClaude256//
257// We deliberately use `private, no-cache, must-revalidate` rather than
258// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
259// which makes every Back/Forward press a cold server round-trip — that
260// contributed to the "every nav feels like a fresh login" UX complaint.
261// `no-cache` still revalidates on direct fetch but lets bfcache hold the
262// page in memory between navigations.
290ea77Claude263app.use("*", async (c, next) => {
264 await next();
265 const ct = c.res.headers.get("content-type") || "";
266 if (ct.startsWith("text/html")) {
36cc17aClaude267 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude268 }
269});
826eccfTest User270// Rate-limit API + auth endpoints.
271//
a41e675Test User272// `/api/*`: 1000/min per IP — generous so an admin clicking around the
273// operator console (or a CDN/proxy concentrating multiple users behind one
274// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
275// rate limits below, not this one.
276//
277// `authedMultiplier` is set but only fires when an upstream middleware has
278// already populated c.get("user") — most app.use() chains apply softAuth
279// per-route, so the multiplier is best-effort. Keep the anonymous base
280// high enough that humans never feel it.
281//
282// Skip-paths: dashboard plumbing endpoints that the layout polls on a
283// fixed cadence and that we don't want consuming any bucket:
284// /api/version — layout polls every 15s
826eccfTest User285// /api/notifications/count — nav bell unread-count fetcher
286// /pwa/vapid-public-key — fetched once per push-notification opt-in
287app.use(
288 "/api/*",
a41e675Test User289 rateLimit(1000, 60_000, "api", {
826eccfTest User290 authedMultiplier: 4,
291 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
292 })
293);
0316dbbClaude294app.use("/login", rateLimit(20, 60_000, "login"));
295app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude296// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
297app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User298// BLOCK Q2 — throttle magic-link sign-in for the same reason.
299app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude300
59b6fb2Claude301// CSRF protection — set token on all requests, validate on mutations
302app.use("*", csrfToken);
303app.use("*", csrfProtect);
304
45e31d0Claude305// Rate limit auth routes
306app.use("/login", authRateLimit);
307app.use("/register", authRateLimit);
308
59b6fb2Claude309// Rate limit git operations
310app.use("/:owner/:repo.git/*", gitRateLimit);
311
312// Rate limit search
313app.use("/:owner/:repo/search", searchRateLimit);
314app.use("/explore", searchRateLimit);
79136bbClaude315
316// Git Smart HTTP protocol routes (must be before web routes)
317app.route("/", gitRoutes);
318
45e31d0Claude319// REST API v1 (legacy)
79136bbClaude320app.route("/", apiRoutes);
321
52ad8b1Claude322// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
323// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
324// router's catch-shape, and BEFORE adminRoutes so the live /demo page
325// wins over the legacy /demo redirect in src/routes/admin.tsx.
326app.route("/", demoRoutes);
327
0316dbbClaude328// REST API v2 (basePath /api/v2)
329app.route("/", apiV2Routes);
330
e75eddcClaude331// Agent multiplayer v1 — /api/v2/agents/* (sessions, leases, usage).
332// Mounted alongside apiV2Routes (its own basePath, no path conflict).
333app.route("/", agentsRoutes);
334
ad6d4adClaude335// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
336app.route("/", hookRoutes);
21f8dbdClaude337app.route("/api/events", eventsRoutes);
ad6d4adClaude338
45e31d0Claude339// API documentation
340app.route("/", apiDocsRoutes);
4a80519Claude341app.route("/", buildAgentSpecRoutes);
a6ff0f2Claude342// PR command center — global PR dashboard with AI/GateTest/auto-merge signal
343app.route("/", pullsDashboardRoutes);
e9aa4d8Claude344// Issue command center — global issue dashboard with AI-triage + autopilot signal
345app.route("/", issuesDashboardRoutes);
346// Personal activity timeline — every event across the user's repos, with
347// AI-driven events surfaced separately (the Gluecron differentiator).
348app.route("/", activityRoutes);
349// Unified inbox — mentions + review requests + CI failures + AI events in one timeline
350app.route("/", inboxRoutes);
56801e1Claude351// AI standup feed — daily / weekly Claude-generated team brief
352app.route("/", standupRoutes);
79136bbClaude353
354// Auth routes (register, login, logout)
355app.route("/", authRoutes);
356
c63b860Claude357// BLOCK P1 — Password reset (forgot-password + reset-password)
358app.route("/", passwordResetRoutes);
359
360// BLOCK P2 — Email verification (verify-email + resend)
361app.route("/", emailVerificationRoutes);
362
cd4f63bTest User363// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
364app.route("/", magicLinkRoutes);
365
79136bbClaude366// Settings routes (profile, SSH keys)
367app.route("/", settingsRoutes);
368
7298a17Claude369// 2FA / TOTP settings (Block B4)
370app.route("/", settings2faRoutes);
371
e75eddcClaude372// Agent multiplayer — /settings/agents management UI
373app.route("/", settingsAgentsRoutes);
374
2df1f8cClaude375// WebAuthn / passkey routes (Block B5)
376app.route("/", passkeyRoutes);
377
058d752Claude378// OAuth 2.0 provider (Block B6)
379app.route("/", oauthRoutes);
380app.route("/", developerAppsRoutes);
381
6fc53bdClaude382// Theme toggle (dark/light cookie)
383app.route("/", themeRoutes);
384
385// Audit log UI
386app.route("/", auditRoutes);
387
388// Reactions API (issues, PRs, comments)
389app.route("/", reactionRoutes);
390
24cf2caClaude391// Saved replies (per-user canned comment templates)
392app.route("/", savedReplyRoutes);
393
394// Environments + deployment history UI
395app.route("/", deploymentRoutes);
396
6563f0aClaude397// Organizations + teams (Block B1)
398app.route("/", orgRoutes);
399
c81ab7aClaude400// API tokens
401app.route("/", tokenRoutes);
402
59b6fb2Claude403// Notifications
3ef4c9dClaude404app.route("/", notificationRoutes);
405
79136bbClaude406// Repo settings (description, visibility, delete)
407app.route("/", repoSettings);
408
23d1a81Claude409// Repo collaborators (add/list/remove)
410app.route("/", collaboratorRoutes);
411
04f6b7fClaude412// Team-based repo collaborators (invite a whole team)
413app.route("/", teamCollaboratorRoutes);
414
415// Collaborator invite accept flow (token-based)
416app.route("/", invitesRoutes);
417
418// Real-time SSE endpoint (topic-based live updates)
419app.route("/", liveEventsRoutes);
420
c81ab7aClaude421// Webhooks management
422app.route("/", webhookRoutes);
423
79136bbClaude424// Compare view (branch diffs)
425app.route("/", compareRoutes);
426
427// Issue tracker
428app.route("/", issueRoutes);
429
0074234Claude430// Pull requests
431app.route("/", pullRoutes);
432
c81ab7aClaude433// Fork
434app.route("/", forkRoutes);
435
0074234Claude436// Web file editor
437app.route("/", editorRoutes);
438
43de941Claude439// Contributors
440app.route("/", contributorRoutes);
441
699e5c7Claude442// Health liveness + metrics endpoints
2c34075Claude443app.route("/", healthRoutes);
444
f295f78Dictation App445// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
446app.route("/api/platform-status", platformStatus);
447
52ad8b1Claude448// Block L4 — Public stats counters (powers landing-page social proof)
449app.route("/", publicStatsRoutes);
450
451// Block L3 — Live /demo page + /api/v2/demo/* endpoints
452app.route("/", demoRoutes);
453
2316be6Claude454// Public /status — human-readable platform health page
455app.route("/", statusRoutes);
456
b1be050CC LABS App457// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
458// Mounted near the public status route so the two surfaces are visible
459// side-by-side; routes are gated by isSiteAdmin internally.
460app.route("/", adminStatusRoutes);
461
80bed05Claude462// /help — quickstart + API cheatsheet
463app.route("/", helpRoutes);
464
5f2e749Claude465// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
466// so the new editorial pricing layout wins the route; the legacy marketing
467// pricing remains as a safety net but is shadowed at the router.
468app.route("/", pricingRoutes);
469
b0148e9Claude470// /pricing, /features, /about — marketing surface
471app.route("/", marketingRoutes);
472
5618f9aClaude473// SEO: robots.txt + sitemap.xml
474app.route("/", seoRoutes);
475
05cdb85Claude476// /api/version — live build SHA + uptime; client poller uses this to
477// surface 'New version available — reload' banners on deploy.
478app.route("/", versionRoutes);
479
699e5c7Claude480// Health dashboard (per-repo health page)
481app.route("/", healthDashboardRoutes);
482
9dd96b9Test User483// Block R1 — site-admin operations console. MUST be mounted BEFORE
484// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
485// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
486app.route("/", adminOpsRoutes);
f2c00b4CC LABS App487// BLOCK W — Self-host status + bootstrap dashboard.
488app.route("/", adminSelfHostRoutes);
826eccfTest User489// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
490app.route("/", adminDiagnoseRoutes);
9dd96b9Test User491
16b325cClaude492// Insights (time-travel, dependencies, rollback)
493app.route("/", insightRoutes);
494
f1ab587Claude495// Command center dashboard
496app.route("/", dashboardRoutes);
497
36b4cbdClaude498// Legal pages (terms, privacy, AUP)
499app.route("/", legalRoutes);
4b66018Claude500// Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}.
501// The main `legal.tsx` serves the short canonical paths (/terms, /privacy,
502// /acceptable-use); these are the formal versions that the legal pages
503// internally link to each other.
504app.route("/", legalTermsRoutes);
505app.route("/", legalPrivacyRoutes);
506app.route("/", legalAcceptableUseRoutes);
507app.route("/", legalDmcaRoutes);
36b4cbdClaude508
bdbd0deClaude509// GitHub import / migration
510app.route("/", importRoutes);
14c3cc8Claude511app.route("/", importBulkRoutes);
f390cfaCC LABS App512app.route("/", importSecretsRoutes);
14c3cc8Claude513app.route("/", migrationRoutes);
514
515// Spec-to-PR (experimental AI-generated draft PRs)
516app.route("/", specsRoutes);
bdbd0deClaude517
c81ab7aClaude518// Explore page
519app.route("/", exploreRoutes);
520
59b6fb2Claude521// Onboarding
522app.route("/", onboardingRoutes);
523
0316dbbClaude524// Admin + feature routes
525app.route("/", adminRoutes);
509c376Claude526app.route("/", adminIntegrationsRoutes);
f764c07Claude527app.route("/", adminDeploysRoutes);
528app.route("/", adminDeploysPageRoutes);
9dd96b9Test User529// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude530app.route("/", advisoriesRoutes);
531app.route("/", aiChangelogRoutes);
532app.route("/", aiExplainRoutes);
533app.route("/", aiTestsRoutes);
534app.route("/", askRoutes);
535app.route("/", billingRoutes);
6778ad2Claude536app.route("/", stripeWebhookRoutes);
0316dbbClaude537app.route("/", codeScanningRoutes);
538app.route("/", commitStatusesRoutes);
539app.route("/", copilotRoutes);
540app.route("/", depUpdaterRoutes);
541app.route("/", depsRoutes);
542app.route("/", discussionsRoutes);
543app.route("/", environmentsRoutes);
544app.route("/", followsRoutes);
545app.route("/", gatesRoutes);
546app.route("/", gistsRoutes);
547app.route("/", graphqlRoutes);
2c2163eClaude548app.route("/", mcpRoutes);
0316dbbClaude549app.route("/", marketplaceRoutes);
550app.route("/", mergeQueueRoutes);
551app.route("/", mirrorsRoutes);
552app.route("/", orgInsightsRoutes);
553app.route("/", packagesRoutes);
554app.route("/", packagesApiRoutes);
555app.route("/", pagesRoutes);
556app.route("/", projectsRoutes);
557app.route("/", protectedTagsRoutes);
558app.route("/", pwaRoutes);
46d6165Claude559app.route("/", installRoutes);
cd4f63bTest User560// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
561app.route("/", dxtRoutes);
662ce86Claude562// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
563// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
564app.route("/", connectClaudeRoutes);
0316dbbClaude565app.route("/", releasesRoutes);
566app.route("/", requiredChecksRoutes);
567app.route("/", rulesetsRoutes);
568app.route("/", searchRoutes);
569app.route("/", semanticSearchRoutes);
570app.route("/", signingKeysRoutes);
571app.route("/", sponsorsRoutes);
572app.route("/", ssoRoutes);
46d6165Claude573app.route("/", githubOauthRoutes);
582cdacClaude574app.route("/", googleOauthRoutes);
0316dbbClaude575app.route("/", symbolsRoutes);
576app.route("/", templatesRoutes);
577app.route("/", trafficRoutes);
578app.route("/", wikisRoutes);
579app.route("/", workflowsRoutes);
5ff9cc2Claude580app.route("/", workflowArtifactsRoutes);
581app.route("/", workflowSecretsRoutes);
46d6165Claude582app.route("/", sleepModeRoutes);
52ad8b1Claude583app.route("/", vsGithubRoutes);
0316dbbClaude584
45f3b73Claude585// Voice-to-PR — phone-first dictation → spec or issue
586app.route("/", voiceRoutes);
587
cd4f63bTest User588// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
589// before the web catch-all so the bare `/play` literal wins over the
590// `/:owner` user-profile route.
591app.route("/", playgroundRoutes);
592
79136bbClaude593// Web UI (catch-all, must be last)
594app.route("/", webRoutes);
595
c63b860Claude596// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
597// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude598app.notFound((c) => {
36cc17aClaude599 const user = c.get("user") ?? null;
79136bbClaude600 return c.html(
c63b860Claude601 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude602 404
603 );
604});
605
c63b860Claude606// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
607// view. Trace block only shown outside production.
79136bbClaude608app.onError((err, c) => {
80bed05Claude609 reportError(err, {
610 requestId: c.get("requestId"),
611 path: c.req.path,
612 method: c.req.method,
613 });
c63b860Claude614 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
615 // back to the context value set by request-context middleware.
616 const requestId =
617 c.req.header("x-request-id") ||
618 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude619 const user = c.get("user") ?? null;
c63b860Claude620 const trace =
621 process.env.NODE_ENV !== "production" && err && err.message
622 ? err.message
623 : undefined;
79136bbClaude624 return c.html(
c63b860Claude625 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude626 500
627 );
628});
629
630export default app;