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.tsxBlame601 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";
79136bbClaude16import authRoutes from "./routes/auth";
c63b860Claude17import passwordResetRoutes from "./routes/password-reset";
18import emailVerificationRoutes from "./routes/email-verification";
cd4f63bTest User19import magicLinkRoutes from "./routes/magic-link";
79136bbClaude20import settingsRoutes from "./routes/settings";
7298a17Claude21import settings2faRoutes from "./routes/settings-2fa";
79136bbClaude22import issueRoutes from "./routes/issues";
23import repoSettings from "./routes/repo-settings";
23d1a81Claude24import collaboratorRoutes from "./routes/collaborators";
04f6b7fClaude25import teamCollaboratorRoutes from "./routes/team-collaborators";
26import invitesRoutes from "./routes/invites";
27import liveEventsRoutes from "./routes/live-events";
79136bbClaude28import compareRoutes from "./routes/compare";
0074234Claude29import pullRoutes from "./routes/pulls";
30import editorRoutes from "./routes/editor";
c81ab7aClaude31import forkRoutes from "./routes/fork";
32import webhookRoutes from "./routes/webhooks";
33import exploreRoutes from "./routes/explore";
34import tokenRoutes from "./routes/tokens";
43de941Claude35import contributorRoutes from "./routes/contributors";
699e5c7Claude36import healthRoutes from "./routes/health-probe";
37import healthDashboardRoutes from "./routes/health";
2316be6Claude38import statusRoutes from "./routes/status";
b1be050CC LABS App39import adminStatusRoutes from "./routes/admin-status";
80bed05Claude40import helpRoutes from "./routes/help";
b0148e9Claude41import marketingRoutes from "./routes/marketing";
5f2e749Claude42import pricingRoutes from "./routes/pricing";
5618f9aClaude43import seoRoutes from "./routes/seo";
05cdb85Claude44import versionRoutes from "./routes/version";
f295f78Dictation App45import { platformStatus } from "./routes/platform-status";
52ad8b1Claude46import publicStatsRoutes from "./routes/public-stats";
47import demoRoutes from "./routes/demo";
16b325cClaude48import insightRoutes from "./routes/insights";
f1ab587Claude49import dashboardRoutes from "./routes/dashboard";
36b4cbdClaude50import legalRoutes from "./routes/legal";
4b66018Claude51import legalDmcaRoutes from "./routes/legal/dmca";
52import legalTermsRoutes from "./routes/legal/terms";
53import legalPrivacyRoutes from "./routes/legal/privacy";
54import legalAcceptableUseRoutes from "./routes/legal/acceptable-use";
bdbd0deClaude55import importRoutes from "./routes/import";
14c3cc8Claude56import importBulkRoutes from "./routes/import-bulk";
f390cfaCC LABS App57import importSecretsRoutes from "./routes/import-secrets";
14c3cc8Claude58import migrationRoutes from "./routes/migrations";
59import specsRoutes from "./routes/specs";
79136bbClaude60import webRoutes from "./routes/web";
0316dbbClaude61import hookRoutes from "./routes/hooks";
62import eventsRoutes from "./routes/events";
63import passkeyRoutes from "./routes/passkeys";
64import oauthRoutes from "./routes/oauth";
65import developerAppsRoutes from "./routes/developer-apps";
66import themeRoutes from "./routes/theme";
67import auditRoutes from "./routes/audit";
68import reactionRoutes from "./routes/reactions";
69import savedReplyRoutes from "./routes/saved-replies";
70import deploymentRoutes from "./routes/deployments";
71import orgRoutes from "./routes/orgs";
72import notificationRoutes from "./routes/notifications";
73import onboardingRoutes from "./routes/onboarding";
74import adminRoutes from "./routes/admin";
f764c07Claude75import adminDeploysRoutes from "./routes/admin-deploys";
76import adminDeploysPageRoutes from "./routes/admin-deploys-page";
9dd96b9Test User77import adminOpsRoutes from "./routes/admin-ops";
f2c00b4CC LABS App78import adminSelfHostRoutes from "./routes/admin-self-host";
826eccfTest User79import adminDiagnoseRoutes from "./routes/admin-diagnose";
509c376Claude80import adminIntegrationsRoutes from "./routes/admin-integrations";
0316dbbClaude81import advisoriesRoutes from "./routes/advisories";
82import aiChangelogRoutes from "./routes/ai-changelog";
83import aiExplainRoutes from "./routes/ai-explain";
84import aiTestsRoutes from "./routes/ai-tests";
85import askRoutes from "./routes/ask";
86import billingRoutes from "./routes/billing";
6778ad2Claude87import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude88import codeScanningRoutes from "./routes/code-scanning";
89import commitStatusesRoutes from "./routes/commit-statuses";
90import copilotRoutes from "./routes/copilot";
91import depUpdaterRoutes from "./routes/dep-updater";
92import depsRoutes from "./routes/deps";
93import discussionsRoutes from "./routes/discussions";
94import environmentsRoutes from "./routes/environments";
95import followsRoutes from "./routes/follows";
96import gatesRoutes from "./routes/gates";
97import gistsRoutes from "./routes/gists";
98import graphqlRoutes from "./routes/graphql";
2c2163eClaude99import mcpRoutes from "./routes/mcp";
0316dbbClaude100import marketplaceRoutes from "./routes/marketplace";
101import mergeQueueRoutes from "./routes/merge-queue";
102import mirrorsRoutes from "./routes/mirrors";
103import orgInsightsRoutes from "./routes/org-insights";
104import packagesRoutes from "./routes/packages";
105import packagesApiRoutes from "./routes/packages-api";
106import pagesRoutes from "./routes/pages";
107import projectsRoutes from "./routes/projects";
108import protectedTagsRoutes from "./routes/protected-tags";
109import pwaRoutes from "./routes/pwa";
46d6165Claude110import installRoutes from "./routes/install";
cd4f63bTest User111import dxtRoutes from "./routes/dxt";
662ce86Claude112import connectClaudeRoutes from "./routes/connect-claude";
0316dbbClaude113import releasesRoutes from "./routes/releases";
114import requiredChecksRoutes from "./routes/required-checks";
115import rulesetsRoutes from "./routes/rulesets";
116import searchRoutes from "./routes/search";
117import semanticSearchRoutes from "./routes/semantic-search";
118import signingKeysRoutes from "./routes/signing-keys";
119import sponsorsRoutes from "./routes/sponsors";
120import ssoRoutes from "./routes/sso";
46d6165Claude121import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude122import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude123import symbolsRoutes from "./routes/symbols";
124import templatesRoutes from "./routes/templates";
125import trafficRoutes from "./routes/traffic";
126import wikisRoutes from "./routes/wikis";
127import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude128import workflowArtifactsRoutes from "./routes/workflow-artifacts";
129import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude130import sleepModeRoutes from "./routes/sleep-mode";
52ad8b1Claude131import vsGithubRoutes from "./routes/vs-github";
cd4f63bTest User132import playgroundRoutes from "./routes/playground";
59b6fb2Claude133import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
134import { csrfToken, csrfProtect } from "./middleware/csrf";
79136bbClaude135
2316901Claude136import type { AuthEnv } from "./middleware/auth";
bf19c50Test User137import { softAuth } from "./middleware/auth";
2316901Claude138
139const app = new Hono<AuthEnv>();
79136bbClaude140
3ef4c9dClaude141// Request context (request ID, start time) runs before everything else
142app.use("*", requestContext);
05b973eClaude143// Middleware — compression first (wraps all responses)
144app.use("*", compress());
f1ffd50Claude145
146// ETag middleware — returns 304 Not Modified on unchanged responses.
147// Saves ~95% bandwidth on repeat visits. Skipped on git protocol +
148// SSE + the API surface where it would interfere with streaming.
149app.use("*", async (c, next) => {
150 const p = c.req.path;
151 if (
152 p.includes(".git/") ||
153 p.startsWith("/live-events") ||
154 p.startsWith("/api/events/deploy") ||
155 p.startsWith("/admin/status")
156 ) {
157 return next();
158 }
159 return etag()(c, next);
160});
161
162// Cache-Control middleware — sets sensible defaults on public, anonymous
163// requests. Crontech (when wired as our edge layer) and downstream
164// browsers will honor these. Auth'd users get private,no-store
165// automatically — we never cache responses tied to a session.
166app.use("*", async (c, next) => {
167 await next();
168 // Don't overwrite explicit headers set by route handlers — BUT the
169 // ETag middleware unconditionally sets "private, no-cache, must-
170 // revalidate" so we have to treat that specific value as "no
171 // policy chosen yet" and apply ours. Any route that explicitly set
172 // a different cache-control wins.
173 const existing = c.res.headers.get("cache-control");
174 const etagDefault =
175 existing === "private, no-cache, must-revalidate" ||
176 existing === "no-cache";
177 if (existing && !etagDefault) return;
178 // Anything past auth: private + no-store (avoid leaking session
179 // content into shared caches). softAuth runs before this on the
180 // request, but the response side is what we're stamping.
181 const hasSession = c.req.header("cookie")?.includes("session=") ?? false;
182 const p = c.req.path;
183 // Always private for known-authed paths regardless of cookie.
184 if (
185 p.startsWith("/admin") ||
186 p.startsWith("/settings") ||
187 p.startsWith("/dashboard") ||
188 p.startsWith("/notifications") ||
189 p.startsWith("/connect/") ||
190 hasSession
191 ) {
192 c.res.headers.set("cache-control", "private, no-store");
193 return;
194 }
195 // Public marketing surfaces — short edge cache, longer browser cache,
196 // stale-while-revalidate so the user never waits on a stale fetch.
197 const isMarketing =
198 p === "/" ||
199 p === "/features" ||
200 p === "/pricing" ||
201 p === "/about" ||
202 p === "/vs-github" ||
203 p === "/explore" ||
204 p === "/help" ||
205 p === "/changelog" ||
206 p.startsWith("/legal/") ||
207 p === "/terms" ||
208 p === "/privacy" ||
209 p === "/acceptable-use" ||
210 p.startsWith("/docs/");
211 if (isMarketing) {
212 c.res.headers.set(
213 "cache-control",
214 "public, max-age=60, s-maxage=300, stale-while-revalidate=86400"
215 );
216 return;
217 }
218 // Public repo browse pages — cache aggressively. Edge invalidates
219 // on push via the post-receive hook (future Crontech surge purge).
220 if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") {
221 c.res.headers.set(
222 "cache-control",
223 "public, max-age=30, s-maxage=120, stale-while-revalidate=600"
224 );
225 return;
226 }
227 // Default: don't cache anything we haven't explicitly opted in.
228 c.res.headers.set("cache-control", "private, no-store");
229});
05b973eClaude230// Logger only on non-git routes to avoid overhead on clone/push
231app.use("*", async (c, next) => {
232 if (c.req.path.includes(".git/")) return next();
233 return logger()(c, next);
234});
79136bbClaude235app.use("/api/*", cors());
bf19c50Test User236// Global softAuth — populates c.get("user") for every downstream middleware
237// + route. This was previously per-route, which meant rate-limit middleware
238// (and anything else inspecting auth state) always saw a null user. Keep
239// individual routes free to add requireAuth on top for hard gating; this
240// just establishes the user object cheaply.
241app.use("*", softAuth);
290ea77Claude242
36cc17aClaude243// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude244// pre-redesign markup. JSON / static assets keep their own cache rules; only
245// text/html responses get the no-cache stamp. Without this, every push to
246// main left users staring at cached 80s-looking pages from before the design
247// landed.
36cc17aClaude248//
249// We deliberately use `private, no-cache, must-revalidate` rather than
250// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
251// which makes every Back/Forward press a cold server round-trip — that
252// contributed to the "every nav feels like a fresh login" UX complaint.
253// `no-cache` still revalidates on direct fetch but lets bfcache hold the
254// page in memory between navigations.
290ea77Claude255app.use("*", async (c, next) => {
256 await next();
257 const ct = c.res.headers.get("content-type") || "";
258 if (ct.startsWith("text/html")) {
36cc17aClaude259 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude260 }
261});
826eccfTest User262// Rate-limit API + auth endpoints.
263//
a41e675Test User264// `/api/*`: 1000/min per IP — generous so an admin clicking around the
265// operator console (or a CDN/proxy concentrating multiple users behind one
266// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
267// rate limits below, not this one.
268//
269// `authedMultiplier` is set but only fires when an upstream middleware has
270// already populated c.get("user") — most app.use() chains apply softAuth
271// per-route, so the multiplier is best-effort. Keep the anonymous base
272// high enough that humans never feel it.
273//
274// Skip-paths: dashboard plumbing endpoints that the layout polls on a
275// fixed cadence and that we don't want consuming any bucket:
276// /api/version — layout polls every 15s
826eccfTest User277// /api/notifications/count — nav bell unread-count fetcher
278// /pwa/vapid-public-key — fetched once per push-notification opt-in
279app.use(
280 "/api/*",
a41e675Test User281 rateLimit(1000, 60_000, "api", {
826eccfTest User282 authedMultiplier: 4,
283 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
284 })
285);
0316dbbClaude286app.use("/login", rateLimit(20, 60_000, "login"));
287app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude288// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
289app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User290// BLOCK Q2 — throttle magic-link sign-in for the same reason.
291app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude292
59b6fb2Claude293// CSRF protection — set token on all requests, validate on mutations
294app.use("*", csrfToken);
295app.use("*", csrfProtect);
296
45e31d0Claude297// Rate limit auth routes
298app.use("/login", authRateLimit);
299app.use("/register", authRateLimit);
300
59b6fb2Claude301// Rate limit git operations
302app.use("/:owner/:repo.git/*", gitRateLimit);
303
304// Rate limit search
305app.use("/:owner/:repo/search", searchRateLimit);
306app.use("/explore", searchRateLimit);
79136bbClaude307
308// Git Smart HTTP protocol routes (must be before web routes)
309app.route("/", gitRoutes);
310
45e31d0Claude311// REST API v1 (legacy)
79136bbClaude312app.route("/", apiRoutes);
313
52ad8b1Claude314// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
315// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
316// router's catch-shape, and BEFORE adminRoutes so the live /demo page
317// wins over the legacy /demo redirect in src/routes/admin.tsx.
318app.route("/", demoRoutes);
319
0316dbbClaude320// REST API v2 (basePath /api/v2)
321app.route("/", apiV2Routes);
322
ad6d4adClaude323// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
324app.route("/", hookRoutes);
21f8dbdClaude325app.route("/api/events", eventsRoutes);
ad6d4adClaude326
45e31d0Claude327// API documentation
328app.route("/", apiDocsRoutes);
4a80519Claude329app.route("/", buildAgentSpecRoutes);
79136bbClaude330
331// Auth routes (register, login, logout)
332app.route("/", authRoutes);
333
c63b860Claude334// BLOCK P1 — Password reset (forgot-password + reset-password)
335app.route("/", passwordResetRoutes);
336
337// BLOCK P2 — Email verification (verify-email + resend)
338app.route("/", emailVerificationRoutes);
339
cd4f63bTest User340// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
341app.route("/", magicLinkRoutes);
342
79136bbClaude343// Settings routes (profile, SSH keys)
344app.route("/", settingsRoutes);
345
7298a17Claude346// 2FA / TOTP settings (Block B4)
347app.route("/", settings2faRoutes);
348
2df1f8cClaude349// WebAuthn / passkey routes (Block B5)
350app.route("/", passkeyRoutes);
351
058d752Claude352// OAuth 2.0 provider (Block B6)
353app.route("/", oauthRoutes);
354app.route("/", developerAppsRoutes);
355
6fc53bdClaude356// Theme toggle (dark/light cookie)
357app.route("/", themeRoutes);
358
359// Audit log UI
360app.route("/", auditRoutes);
361
362// Reactions API (issues, PRs, comments)
363app.route("/", reactionRoutes);
364
24cf2caClaude365// Saved replies (per-user canned comment templates)
366app.route("/", savedReplyRoutes);
367
368// Environments + deployment history UI
369app.route("/", deploymentRoutes);
370
6563f0aClaude371// Organizations + teams (Block B1)
372app.route("/", orgRoutes);
373
c81ab7aClaude374// API tokens
375app.route("/", tokenRoutes);
376
59b6fb2Claude377// Notifications
3ef4c9dClaude378app.route("/", notificationRoutes);
379
79136bbClaude380// Repo settings (description, visibility, delete)
381app.route("/", repoSettings);
382
23d1a81Claude383// Repo collaborators (add/list/remove)
384app.route("/", collaboratorRoutes);
385
04f6b7fClaude386// Team-based repo collaborators (invite a whole team)
387app.route("/", teamCollaboratorRoutes);
388
389// Collaborator invite accept flow (token-based)
390app.route("/", invitesRoutes);
391
392// Real-time SSE endpoint (topic-based live updates)
393app.route("/", liveEventsRoutes);
394
c81ab7aClaude395// Webhooks management
396app.route("/", webhookRoutes);
397
79136bbClaude398// Compare view (branch diffs)
399app.route("/", compareRoutes);
400
401// Issue tracker
402app.route("/", issueRoutes);
403
0074234Claude404// Pull requests
405app.route("/", pullRoutes);
406
c81ab7aClaude407// Fork
408app.route("/", forkRoutes);
409
0074234Claude410// Web file editor
411app.route("/", editorRoutes);
412
43de941Claude413// Contributors
414app.route("/", contributorRoutes);
415
699e5c7Claude416// Health liveness + metrics endpoints
2c34075Claude417app.route("/", healthRoutes);
418
f295f78Dictation App419// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
420app.route("/api/platform-status", platformStatus);
421
52ad8b1Claude422// Block L4 — Public stats counters (powers landing-page social proof)
423app.route("/", publicStatsRoutes);
424
425// Block L3 — Live /demo page + /api/v2/demo/* endpoints
426app.route("/", demoRoutes);
427
2316be6Claude428// Public /status — human-readable platform health page
429app.route("/", statusRoutes);
430
b1be050CC LABS App431// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
432// Mounted near the public status route so the two surfaces are visible
433// side-by-side; routes are gated by isSiteAdmin internally.
434app.route("/", adminStatusRoutes);
435
80bed05Claude436// /help — quickstart + API cheatsheet
437app.route("/", helpRoutes);
438
5f2e749Claude439// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
440// so the new editorial pricing layout wins the route; the legacy marketing
441// pricing remains as a safety net but is shadowed at the router.
442app.route("/", pricingRoutes);
443
b0148e9Claude444// /pricing, /features, /about — marketing surface
445app.route("/", marketingRoutes);
446
5618f9aClaude447// SEO: robots.txt + sitemap.xml
448app.route("/", seoRoutes);
449
05cdb85Claude450// /api/version — live build SHA + uptime; client poller uses this to
451// surface 'New version available — reload' banners on deploy.
452app.route("/", versionRoutes);
453
699e5c7Claude454// Health dashboard (per-repo health page)
455app.route("/", healthDashboardRoutes);
456
9dd96b9Test User457// Block R1 — site-admin operations console. MUST be mounted BEFORE
458// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
459// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
460app.route("/", adminOpsRoutes);
f2c00b4CC LABS App461// BLOCK W — Self-host status + bootstrap dashboard.
462app.route("/", adminSelfHostRoutes);
826eccfTest User463// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
464app.route("/", adminDiagnoseRoutes);
9dd96b9Test User465
16b325cClaude466// Insights (time-travel, dependencies, rollback)
467app.route("/", insightRoutes);
468
f1ab587Claude469// Command center dashboard
470app.route("/", dashboardRoutes);
471
36b4cbdClaude472// Legal pages (terms, privacy, AUP)
473app.route("/", legalRoutes);
4b66018Claude474// Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}.
475// The main `legal.tsx` serves the short canonical paths (/terms, /privacy,
476// /acceptable-use); these are the formal versions that the legal pages
477// internally link to each other.
478app.route("/", legalTermsRoutes);
479app.route("/", legalPrivacyRoutes);
480app.route("/", legalAcceptableUseRoutes);
481app.route("/", legalDmcaRoutes);
36b4cbdClaude482
bdbd0deClaude483// GitHub import / migration
484app.route("/", importRoutes);
14c3cc8Claude485app.route("/", importBulkRoutes);
f390cfaCC LABS App486app.route("/", importSecretsRoutes);
14c3cc8Claude487app.route("/", migrationRoutes);
488
489// Spec-to-PR (experimental AI-generated draft PRs)
490app.route("/", specsRoutes);
bdbd0deClaude491
c81ab7aClaude492// Explore page
493app.route("/", exploreRoutes);
494
59b6fb2Claude495// Onboarding
496app.route("/", onboardingRoutes);
497
0316dbbClaude498// Admin + feature routes
499app.route("/", adminRoutes);
509c376Claude500app.route("/", adminIntegrationsRoutes);
f764c07Claude501app.route("/", adminDeploysRoutes);
502app.route("/", adminDeploysPageRoutes);
9dd96b9Test User503// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude504app.route("/", advisoriesRoutes);
505app.route("/", aiChangelogRoutes);
506app.route("/", aiExplainRoutes);
507app.route("/", aiTestsRoutes);
508app.route("/", askRoutes);
509app.route("/", billingRoutes);
6778ad2Claude510app.route("/", stripeWebhookRoutes);
0316dbbClaude511app.route("/", codeScanningRoutes);
512app.route("/", commitStatusesRoutes);
513app.route("/", copilotRoutes);
514app.route("/", depUpdaterRoutes);
515app.route("/", depsRoutes);
516app.route("/", discussionsRoutes);
517app.route("/", environmentsRoutes);
518app.route("/", followsRoutes);
519app.route("/", gatesRoutes);
520app.route("/", gistsRoutes);
521app.route("/", graphqlRoutes);
2c2163eClaude522app.route("/", mcpRoutes);
0316dbbClaude523app.route("/", marketplaceRoutes);
524app.route("/", mergeQueueRoutes);
525app.route("/", mirrorsRoutes);
526app.route("/", orgInsightsRoutes);
527app.route("/", packagesRoutes);
528app.route("/", packagesApiRoutes);
529app.route("/", pagesRoutes);
530app.route("/", projectsRoutes);
531app.route("/", protectedTagsRoutes);
532app.route("/", pwaRoutes);
46d6165Claude533app.route("/", installRoutes);
cd4f63bTest User534// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
535app.route("/", dxtRoutes);
662ce86Claude536// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
537// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
538app.route("/", connectClaudeRoutes);
0316dbbClaude539app.route("/", releasesRoutes);
540app.route("/", requiredChecksRoutes);
541app.route("/", rulesetsRoutes);
542app.route("/", searchRoutes);
543app.route("/", semanticSearchRoutes);
544app.route("/", signingKeysRoutes);
545app.route("/", sponsorsRoutes);
546app.route("/", ssoRoutes);
46d6165Claude547app.route("/", githubOauthRoutes);
582cdacClaude548app.route("/", googleOauthRoutes);
0316dbbClaude549app.route("/", symbolsRoutes);
550app.route("/", templatesRoutes);
551app.route("/", trafficRoutes);
552app.route("/", wikisRoutes);
553app.route("/", workflowsRoutes);
5ff9cc2Claude554app.route("/", workflowArtifactsRoutes);
555app.route("/", workflowSecretsRoutes);
46d6165Claude556app.route("/", sleepModeRoutes);
52ad8b1Claude557app.route("/", vsGithubRoutes);
0316dbbClaude558
cd4f63bTest User559// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
560// before the web catch-all so the bare `/play` literal wins over the
561// `/:owner` user-profile route.
562app.route("/", playgroundRoutes);
563
79136bbClaude564// Web UI (catch-all, must be last)
565app.route("/", webRoutes);
566
c63b860Claude567// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
568// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude569app.notFound((c) => {
36cc17aClaude570 const user = c.get("user") ?? null;
79136bbClaude571 return c.html(
c63b860Claude572 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude573 404
574 );
575});
576
c63b860Claude577// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
578// view. Trace block only shown outside production.
79136bbClaude579app.onError((err, c) => {
80bed05Claude580 reportError(err, {
581 requestId: c.get("requestId"),
582 path: c.req.path,
583 method: c.req.method,
584 });
c63b860Claude585 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
586 // back to the context value set by request-context middleware.
587 const requestId =
588 c.req.header("x-request-id") ||
589 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude590 const user = c.get("user") ?? null;
c63b860Claude591 const trace =
592 process.env.NODE_ENV !== "production" && err && err.message
593 ? err.message
594 : undefined;
79136bbClaude595 return c.html(
c63b860Claude596 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude597 500
598 );
599});
600
601export default app;