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.tsxBlame617 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";
79136bbClaude26import issueRoutes from "./routes/issues";
27import repoSettings from "./routes/repo-settings";
23d1a81Claude28import collaboratorRoutes from "./routes/collaborators";
04f6b7fClaude29import teamCollaboratorRoutes from "./routes/team-collaborators";
30import invitesRoutes from "./routes/invites";
31import liveEventsRoutes from "./routes/live-events";
79136bbClaude32import compareRoutes from "./routes/compare";
0074234Claude33import pullRoutes from "./routes/pulls";
34import editorRoutes from "./routes/editor";
c81ab7aClaude35import forkRoutes from "./routes/fork";
36import webhookRoutes from "./routes/webhooks";
37import exploreRoutes from "./routes/explore";
38import tokenRoutes from "./routes/tokens";
43de941Claude39import contributorRoutes from "./routes/contributors";
699e5c7Claude40import healthRoutes from "./routes/health-probe";
41import healthDashboardRoutes from "./routes/health";
2316be6Claude42import statusRoutes from "./routes/status";
b1be050CC LABS App43import adminStatusRoutes from "./routes/admin-status";
80bed05Claude44import helpRoutes from "./routes/help";
b0148e9Claude45import marketingRoutes from "./routes/marketing";
5f2e749Claude46import pricingRoutes from "./routes/pricing";
5618f9aClaude47import seoRoutes from "./routes/seo";
05cdb85Claude48import versionRoutes from "./routes/version";
f295f78Dictation App49import { platformStatus } from "./routes/platform-status";
52ad8b1Claude50import publicStatsRoutes from "./routes/public-stats";
51import demoRoutes from "./routes/demo";
16b325cClaude52import insightRoutes from "./routes/insights";
f1ab587Claude53import dashboardRoutes from "./routes/dashboard";
36b4cbdClaude54import legalRoutes from "./routes/legal";
4b66018Claude55import legalDmcaRoutes from "./routes/legal/dmca";
56import legalTermsRoutes from "./routes/legal/terms";
57import legalPrivacyRoutes from "./routes/legal/privacy";
58import legalAcceptableUseRoutes from "./routes/legal/acceptable-use";
bdbd0deClaude59import importRoutes from "./routes/import";
14c3cc8Claude60import importBulkRoutes from "./routes/import-bulk";
f390cfaCC LABS App61import importSecretsRoutes from "./routes/import-secrets";
14c3cc8Claude62import migrationRoutes from "./routes/migrations";
63import specsRoutes from "./routes/specs";
79136bbClaude64import webRoutes from "./routes/web";
0316dbbClaude65import hookRoutes from "./routes/hooks";
66import eventsRoutes from "./routes/events";
67import passkeyRoutes from "./routes/passkeys";
68import oauthRoutes from "./routes/oauth";
69import developerAppsRoutes from "./routes/developer-apps";
70import themeRoutes from "./routes/theme";
71import auditRoutes from "./routes/audit";
72import reactionRoutes from "./routes/reactions";
73import savedReplyRoutes from "./routes/saved-replies";
74import deploymentRoutes from "./routes/deployments";
75import orgRoutes from "./routes/orgs";
76import notificationRoutes from "./routes/notifications";
77import onboardingRoutes from "./routes/onboarding";
78import adminRoutes from "./routes/admin";
f764c07Claude79import adminDeploysRoutes from "./routes/admin-deploys";
80import adminDeploysPageRoutes from "./routes/admin-deploys-page";
9dd96b9Test User81import adminOpsRoutes from "./routes/admin-ops";
f2c00b4CC LABS App82import adminSelfHostRoutes from "./routes/admin-self-host";
826eccfTest User83import adminDiagnoseRoutes from "./routes/admin-diagnose";
509c376Claude84import adminIntegrationsRoutes from "./routes/admin-integrations";
0316dbbClaude85import advisoriesRoutes from "./routes/advisories";
86import aiChangelogRoutes from "./routes/ai-changelog";
87import aiExplainRoutes from "./routes/ai-explain";
88import aiTestsRoutes from "./routes/ai-tests";
89import askRoutes from "./routes/ask";
90import billingRoutes from "./routes/billing";
6778ad2Claude91import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude92import codeScanningRoutes from "./routes/code-scanning";
93import commitStatusesRoutes from "./routes/commit-statuses";
94import copilotRoutes from "./routes/copilot";
95import depUpdaterRoutes from "./routes/dep-updater";
96import depsRoutes from "./routes/deps";
97import discussionsRoutes from "./routes/discussions";
98import environmentsRoutes from "./routes/environments";
99import followsRoutes from "./routes/follows";
100import gatesRoutes from "./routes/gates";
101import gistsRoutes from "./routes/gists";
102import graphqlRoutes from "./routes/graphql";
2c2163eClaude103import mcpRoutes from "./routes/mcp";
0316dbbClaude104import marketplaceRoutes from "./routes/marketplace";
105import mergeQueueRoutes from "./routes/merge-queue";
106import mirrorsRoutes from "./routes/mirrors";
107import orgInsightsRoutes from "./routes/org-insights";
108import packagesRoutes from "./routes/packages";
109import packagesApiRoutes from "./routes/packages-api";
110import pagesRoutes from "./routes/pages";
111import projectsRoutes from "./routes/projects";
112import protectedTagsRoutes from "./routes/protected-tags";
113import pwaRoutes from "./routes/pwa";
46d6165Claude114import installRoutes from "./routes/install";
cd4f63bTest User115import dxtRoutes from "./routes/dxt";
662ce86Claude116import connectClaudeRoutes from "./routes/connect-claude";
0316dbbClaude117import releasesRoutes from "./routes/releases";
118import requiredChecksRoutes from "./routes/required-checks";
119import rulesetsRoutes from "./routes/rulesets";
120import searchRoutes from "./routes/search";
121import semanticSearchRoutes from "./routes/semantic-search";
122import signingKeysRoutes from "./routes/signing-keys";
123import sponsorsRoutes from "./routes/sponsors";
124import ssoRoutes from "./routes/sso";
46d6165Claude125import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude126import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude127import symbolsRoutes from "./routes/symbols";
128import templatesRoutes from "./routes/templates";
129import trafficRoutes from "./routes/traffic";
130import wikisRoutes from "./routes/wikis";
131import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude132import workflowArtifactsRoutes from "./routes/workflow-artifacts";
133import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude134import sleepModeRoutes from "./routes/sleep-mode";
56801e1Claude135import standupRoutes from "./routes/standups";
52ad8b1Claude136import vsGithubRoutes from "./routes/vs-github";
cd4f63bTest User137import playgroundRoutes from "./routes/playground";
59b6fb2Claude138import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
139import { csrfToken, csrfProtect } from "./middleware/csrf";
79136bbClaude140
2316901Claude141import type { AuthEnv } from "./middleware/auth";
bf19c50Test User142import { softAuth } from "./middleware/auth";
2316901Claude143
144const app = new Hono<AuthEnv>();
79136bbClaude145
3ef4c9dClaude146// Request context (request ID, start time) runs before everything else
147app.use("*", requestContext);
05b973eClaude148// Middleware — compression first (wraps all responses)
149app.use("*", compress());
f1ffd50Claude150
151// ETag middleware — returns 304 Not Modified on unchanged responses.
152// Saves ~95% bandwidth on repeat visits. Skipped on git protocol +
153// SSE + the API surface where it would interfere with streaming.
154app.use("*", async (c, next) => {
155 const p = c.req.path;
156 if (
157 p.includes(".git/") ||
158 p.startsWith("/live-events") ||
159 p.startsWith("/api/events/deploy") ||
160 p.startsWith("/admin/status")
161 ) {
162 return next();
163 }
164 return etag()(c, next);
165});
166
167// Cache-Control middleware — sets sensible defaults on public, anonymous
168// requests. Crontech (when wired as our edge layer) and downstream
169// browsers will honor these. Auth'd users get private,no-store
170// automatically — we never cache responses tied to a session.
171app.use("*", async (c, next) => {
172 await next();
173 // Don't overwrite explicit headers set by route handlers — BUT the
174 // ETag middleware unconditionally sets "private, no-cache, must-
175 // revalidate" so we have to treat that specific value as "no
176 // policy chosen yet" and apply ours. Any route that explicitly set
177 // a different cache-control wins.
178 const existing = c.res.headers.get("cache-control");
179 const etagDefault =
180 existing === "private, no-cache, must-revalidate" ||
181 existing === "no-cache";
182 if (existing && !etagDefault) return;
183 // Anything past auth: private + no-store (avoid leaking session
184 // content into shared caches). softAuth runs before this on the
185 // request, but the response side is what we're stamping.
186 const hasSession = c.req.header("cookie")?.includes("session=") ?? false;
187 const p = c.req.path;
188 // Always private for known-authed paths regardless of cookie.
189 if (
190 p.startsWith("/admin") ||
191 p.startsWith("/settings") ||
192 p.startsWith("/dashboard") ||
193 p.startsWith("/notifications") ||
194 p.startsWith("/connect/") ||
195 hasSession
196 ) {
197 c.res.headers.set("cache-control", "private, no-store");
198 return;
199 }
200 // Public marketing surfaces — short edge cache, longer browser cache,
201 // stale-while-revalidate so the user never waits on a stale fetch.
202 const isMarketing =
203 p === "/" ||
204 p === "/features" ||
205 p === "/pricing" ||
206 p === "/about" ||
207 p === "/vs-github" ||
208 p === "/explore" ||
209 p === "/help" ||
210 p === "/changelog" ||
211 p.startsWith("/legal/") ||
212 p === "/terms" ||
213 p === "/privacy" ||
214 p === "/acceptable-use" ||
215 p.startsWith("/docs/");
216 if (isMarketing) {
217 c.res.headers.set(
218 "cache-control",
219 "public, max-age=60, s-maxage=300, stale-while-revalidate=86400"
220 );
221 return;
222 }
223 // Public repo browse pages — cache aggressively. Edge invalidates
224 // on push via the post-receive hook (future Crontech surge purge).
225 if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") {
226 c.res.headers.set(
227 "cache-control",
228 "public, max-age=30, s-maxage=120, stale-while-revalidate=600"
229 );
230 return;
231 }
232 // Default: don't cache anything we haven't explicitly opted in.
233 c.res.headers.set("cache-control", "private, no-store");
234});
05b973eClaude235// Logger only on non-git routes to avoid overhead on clone/push
236app.use("*", async (c, next) => {
237 if (c.req.path.includes(".git/")) return next();
238 return logger()(c, next);
239});
79136bbClaude240app.use("/api/*", cors());
bf19c50Test User241// Global softAuth — populates c.get("user") for every downstream middleware
242// + route. This was previously per-route, which meant rate-limit middleware
243// (and anything else inspecting auth state) always saw a null user. Keep
244// individual routes free to add requireAuth on top for hard gating; this
245// just establishes the user object cheaply.
246app.use("*", softAuth);
290ea77Claude247
36cc17aClaude248// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude249// pre-redesign markup. JSON / static assets keep their own cache rules; only
250// text/html responses get the no-cache stamp. Without this, every push to
251// main left users staring at cached 80s-looking pages from before the design
252// landed.
36cc17aClaude253//
254// We deliberately use `private, no-cache, must-revalidate` rather than
255// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
256// which makes every Back/Forward press a cold server round-trip — that
257// contributed to the "every nav feels like a fresh login" UX complaint.
258// `no-cache` still revalidates on direct fetch but lets bfcache hold the
259// page in memory between navigations.
290ea77Claude260app.use("*", async (c, next) => {
261 await next();
262 const ct = c.res.headers.get("content-type") || "";
263 if (ct.startsWith("text/html")) {
36cc17aClaude264 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude265 }
266});
826eccfTest User267// Rate-limit API + auth endpoints.
268//
a41e675Test User269// `/api/*`: 1000/min per IP — generous so an admin clicking around the
270// operator console (or a CDN/proxy concentrating multiple users behind one
271// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
272// rate limits below, not this one.
273//
274// `authedMultiplier` is set but only fires when an upstream middleware has
275// already populated c.get("user") — most app.use() chains apply softAuth
276// per-route, so the multiplier is best-effort. Keep the anonymous base
277// high enough that humans never feel it.
278//
279// Skip-paths: dashboard plumbing endpoints that the layout polls on a
280// fixed cadence and that we don't want consuming any bucket:
281// /api/version — layout polls every 15s
826eccfTest User282// /api/notifications/count — nav bell unread-count fetcher
283// /pwa/vapid-public-key — fetched once per push-notification opt-in
284app.use(
285 "/api/*",
a41e675Test User286 rateLimit(1000, 60_000, "api", {
826eccfTest User287 authedMultiplier: 4,
288 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
289 })
290);
0316dbbClaude291app.use("/login", rateLimit(20, 60_000, "login"));
292app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude293// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
294app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User295// BLOCK Q2 — throttle magic-link sign-in for the same reason.
296app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude297
59b6fb2Claude298// CSRF protection — set token on all requests, validate on mutations
299app.use("*", csrfToken);
300app.use("*", csrfProtect);
301
45e31d0Claude302// Rate limit auth routes
303app.use("/login", authRateLimit);
304app.use("/register", authRateLimit);
305
59b6fb2Claude306// Rate limit git operations
307app.use("/:owner/:repo.git/*", gitRateLimit);
308
309// Rate limit search
310app.use("/:owner/:repo/search", searchRateLimit);
311app.use("/explore", searchRateLimit);
79136bbClaude312
313// Git Smart HTTP protocol routes (must be before web routes)
314app.route("/", gitRoutes);
315
45e31d0Claude316// REST API v1 (legacy)
79136bbClaude317app.route("/", apiRoutes);
318
52ad8b1Claude319// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
320// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
321// router's catch-shape, and BEFORE adminRoutes so the live /demo page
322// wins over the legacy /demo redirect in src/routes/admin.tsx.
323app.route("/", demoRoutes);
324
0316dbbClaude325// REST API v2 (basePath /api/v2)
326app.route("/", apiV2Routes);
327
ad6d4adClaude328// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
329app.route("/", hookRoutes);
21f8dbdClaude330app.route("/api/events", eventsRoutes);
ad6d4adClaude331
45e31d0Claude332// API documentation
333app.route("/", apiDocsRoutes);
4a80519Claude334app.route("/", buildAgentSpecRoutes);
a6ff0f2Claude335// PR command center — global PR dashboard with AI/GateTest/auto-merge signal
336app.route("/", pullsDashboardRoutes);
e9aa4d8Claude337// Issue command center — global issue dashboard with AI-triage + autopilot signal
338app.route("/", issuesDashboardRoutes);
339// Personal activity timeline — every event across the user's repos, with
340// AI-driven events surfaced separately (the Gluecron differentiator).
341app.route("/", activityRoutes);
342// Unified inbox — mentions + review requests + CI failures + AI events in one timeline
343app.route("/", inboxRoutes);
56801e1Claude344// AI standup feed — daily / weekly Claude-generated team brief
345app.route("/", standupRoutes);
79136bbClaude346
347// Auth routes (register, login, logout)
348app.route("/", authRoutes);
349
c63b860Claude350// BLOCK P1 — Password reset (forgot-password + reset-password)
351app.route("/", passwordResetRoutes);
352
353// BLOCK P2 — Email verification (verify-email + resend)
354app.route("/", emailVerificationRoutes);
355
cd4f63bTest User356// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
357app.route("/", magicLinkRoutes);
358
79136bbClaude359// Settings routes (profile, SSH keys)
360app.route("/", settingsRoutes);
361
7298a17Claude362// 2FA / TOTP settings (Block B4)
363app.route("/", settings2faRoutes);
364
2df1f8cClaude365// WebAuthn / passkey routes (Block B5)
366app.route("/", passkeyRoutes);
367
058d752Claude368// OAuth 2.0 provider (Block B6)
369app.route("/", oauthRoutes);
370app.route("/", developerAppsRoutes);
371
6fc53bdClaude372// Theme toggle (dark/light cookie)
373app.route("/", themeRoutes);
374
375// Audit log UI
376app.route("/", auditRoutes);
377
378// Reactions API (issues, PRs, comments)
379app.route("/", reactionRoutes);
380
24cf2caClaude381// Saved replies (per-user canned comment templates)
382app.route("/", savedReplyRoutes);
383
384// Environments + deployment history UI
385app.route("/", deploymentRoutes);
386
6563f0aClaude387// Organizations + teams (Block B1)
388app.route("/", orgRoutes);
389
c81ab7aClaude390// API tokens
391app.route("/", tokenRoutes);
392
59b6fb2Claude393// Notifications
3ef4c9dClaude394app.route("/", notificationRoutes);
395
79136bbClaude396// Repo settings (description, visibility, delete)
397app.route("/", repoSettings);
398
23d1a81Claude399// Repo collaborators (add/list/remove)
400app.route("/", collaboratorRoutes);
401
04f6b7fClaude402// Team-based repo collaborators (invite a whole team)
403app.route("/", teamCollaboratorRoutes);
404
405// Collaborator invite accept flow (token-based)
406app.route("/", invitesRoutes);
407
408// Real-time SSE endpoint (topic-based live updates)
409app.route("/", liveEventsRoutes);
410
c81ab7aClaude411// Webhooks management
412app.route("/", webhookRoutes);
413
79136bbClaude414// Compare view (branch diffs)
415app.route("/", compareRoutes);
416
417// Issue tracker
418app.route("/", issueRoutes);
419
0074234Claude420// Pull requests
421app.route("/", pullRoutes);
422
c81ab7aClaude423// Fork
424app.route("/", forkRoutes);
425
0074234Claude426// Web file editor
427app.route("/", editorRoutes);
428
43de941Claude429// Contributors
430app.route("/", contributorRoutes);
431
699e5c7Claude432// Health liveness + metrics endpoints
2c34075Claude433app.route("/", healthRoutes);
434
f295f78Dictation App435// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
436app.route("/api/platform-status", platformStatus);
437
52ad8b1Claude438// Block L4 — Public stats counters (powers landing-page social proof)
439app.route("/", publicStatsRoutes);
440
441// Block L3 — Live /demo page + /api/v2/demo/* endpoints
442app.route("/", demoRoutes);
443
2316be6Claude444// Public /status — human-readable platform health page
445app.route("/", statusRoutes);
446
b1be050CC LABS App447// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
448// Mounted near the public status route so the two surfaces are visible
449// side-by-side; routes are gated by isSiteAdmin internally.
450app.route("/", adminStatusRoutes);
451
80bed05Claude452// /help — quickstart + API cheatsheet
453app.route("/", helpRoutes);
454
5f2e749Claude455// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
456// so the new editorial pricing layout wins the route; the legacy marketing
457// pricing remains as a safety net but is shadowed at the router.
458app.route("/", pricingRoutes);
459
b0148e9Claude460// /pricing, /features, /about — marketing surface
461app.route("/", marketingRoutes);
462
5618f9aClaude463// SEO: robots.txt + sitemap.xml
464app.route("/", seoRoutes);
465
05cdb85Claude466// /api/version — live build SHA + uptime; client poller uses this to
467// surface 'New version available — reload' banners on deploy.
468app.route("/", versionRoutes);
469
699e5c7Claude470// Health dashboard (per-repo health page)
471app.route("/", healthDashboardRoutes);
472
9dd96b9Test User473// Block R1 — site-admin operations console. MUST be mounted BEFORE
474// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
475// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
476app.route("/", adminOpsRoutes);
f2c00b4CC LABS App477// BLOCK W — Self-host status + bootstrap dashboard.
478app.route("/", adminSelfHostRoutes);
826eccfTest User479// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
480app.route("/", adminDiagnoseRoutes);
9dd96b9Test User481
16b325cClaude482// Insights (time-travel, dependencies, rollback)
483app.route("/", insightRoutes);
484
f1ab587Claude485// Command center dashboard
486app.route("/", dashboardRoutes);
487
36b4cbdClaude488// Legal pages (terms, privacy, AUP)
489app.route("/", legalRoutes);
4b66018Claude490// Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}.
491// The main `legal.tsx` serves the short canonical paths (/terms, /privacy,
492// /acceptable-use); these are the formal versions that the legal pages
493// internally link to each other.
494app.route("/", legalTermsRoutes);
495app.route("/", legalPrivacyRoutes);
496app.route("/", legalAcceptableUseRoutes);
497app.route("/", legalDmcaRoutes);
36b4cbdClaude498
bdbd0deClaude499// GitHub import / migration
500app.route("/", importRoutes);
14c3cc8Claude501app.route("/", importBulkRoutes);
f390cfaCC LABS App502app.route("/", importSecretsRoutes);
14c3cc8Claude503app.route("/", migrationRoutes);
504
505// Spec-to-PR (experimental AI-generated draft PRs)
506app.route("/", specsRoutes);
bdbd0deClaude507
c81ab7aClaude508// Explore page
509app.route("/", exploreRoutes);
510
59b6fb2Claude511// Onboarding
512app.route("/", onboardingRoutes);
513
0316dbbClaude514// Admin + feature routes
515app.route("/", adminRoutes);
509c376Claude516app.route("/", adminIntegrationsRoutes);
f764c07Claude517app.route("/", adminDeploysRoutes);
518app.route("/", adminDeploysPageRoutes);
9dd96b9Test User519// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude520app.route("/", advisoriesRoutes);
521app.route("/", aiChangelogRoutes);
522app.route("/", aiExplainRoutes);
523app.route("/", aiTestsRoutes);
524app.route("/", askRoutes);
525app.route("/", billingRoutes);
6778ad2Claude526app.route("/", stripeWebhookRoutes);
0316dbbClaude527app.route("/", codeScanningRoutes);
528app.route("/", commitStatusesRoutes);
529app.route("/", copilotRoutes);
530app.route("/", depUpdaterRoutes);
531app.route("/", depsRoutes);
532app.route("/", discussionsRoutes);
533app.route("/", environmentsRoutes);
534app.route("/", followsRoutes);
535app.route("/", gatesRoutes);
536app.route("/", gistsRoutes);
537app.route("/", graphqlRoutes);
2c2163eClaude538app.route("/", mcpRoutes);
0316dbbClaude539app.route("/", marketplaceRoutes);
540app.route("/", mergeQueueRoutes);
541app.route("/", mirrorsRoutes);
542app.route("/", orgInsightsRoutes);
543app.route("/", packagesRoutes);
544app.route("/", packagesApiRoutes);
545app.route("/", pagesRoutes);
546app.route("/", projectsRoutes);
547app.route("/", protectedTagsRoutes);
548app.route("/", pwaRoutes);
46d6165Claude549app.route("/", installRoutes);
cd4f63bTest User550// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
551app.route("/", dxtRoutes);
662ce86Claude552// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
553// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
554app.route("/", connectClaudeRoutes);
0316dbbClaude555app.route("/", releasesRoutes);
556app.route("/", requiredChecksRoutes);
557app.route("/", rulesetsRoutes);
558app.route("/", searchRoutes);
559app.route("/", semanticSearchRoutes);
560app.route("/", signingKeysRoutes);
561app.route("/", sponsorsRoutes);
562app.route("/", ssoRoutes);
46d6165Claude563app.route("/", githubOauthRoutes);
582cdacClaude564app.route("/", googleOauthRoutes);
0316dbbClaude565app.route("/", symbolsRoutes);
566app.route("/", templatesRoutes);
567app.route("/", trafficRoutes);
568app.route("/", wikisRoutes);
569app.route("/", workflowsRoutes);
5ff9cc2Claude570app.route("/", workflowArtifactsRoutes);
571app.route("/", workflowSecretsRoutes);
46d6165Claude572app.route("/", sleepModeRoutes);
52ad8b1Claude573app.route("/", vsGithubRoutes);
0316dbbClaude574
cd4f63bTest User575// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
576// before the web catch-all so the bare `/play` literal wins over the
577// `/:owner` user-profile route.
578app.route("/", playgroundRoutes);
579
79136bbClaude580// Web UI (catch-all, must be last)
581app.route("/", webRoutes);
582
c63b860Claude583// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
584// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude585app.notFound((c) => {
36cc17aClaude586 const user = c.get("user") ?? null;
79136bbClaude587 return c.html(
c63b860Claude588 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude589 404
590 );
591});
592
c63b860Claude593// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
594// view. Trace block only shown outside production.
79136bbClaude595app.onError((err, c) => {
80bed05Claude596 reportError(err, {
597 requestId: c.get("requestId"),
598 path: c.req.path,
599 method: c.req.method,
600 });
c63b860Claude601 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
602 // back to the context value set by request-context middleware.
603 const requestId =
604 c.req.header("x-request-id") ||
605 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude606 const user = c.get("user") ?? null;
c63b860Claude607 const trace =
608 process.env.NODE_ENV !== "production" && err && err.message
609 ? err.message
610 : undefined;
79136bbClaude611 return c.html(
c63b860Claude612 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude613 500
614 );
615});
616
617export default app;