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.tsxBlame604 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";
79136bbClaude17import authRoutes from "./routes/auth";
c63b860Claude18import passwordResetRoutes from "./routes/password-reset";
19import emailVerificationRoutes from "./routes/email-verification";
cd4f63bTest User20import magicLinkRoutes from "./routes/magic-link";
79136bbClaude21import settingsRoutes from "./routes/settings";
7298a17Claude22import settings2faRoutes from "./routes/settings-2fa";
79136bbClaude23import issueRoutes from "./routes/issues";
24import repoSettings from "./routes/repo-settings";
23d1a81Claude25import collaboratorRoutes from "./routes/collaborators";
04f6b7fClaude26import teamCollaboratorRoutes from "./routes/team-collaborators";
27import invitesRoutes from "./routes/invites";
28import liveEventsRoutes from "./routes/live-events";
79136bbClaude29import compareRoutes from "./routes/compare";
0074234Claude30import pullRoutes from "./routes/pulls";
31import editorRoutes from "./routes/editor";
c81ab7aClaude32import forkRoutes from "./routes/fork";
33import webhookRoutes from "./routes/webhooks";
34import exploreRoutes from "./routes/explore";
35import tokenRoutes from "./routes/tokens";
43de941Claude36import contributorRoutes from "./routes/contributors";
699e5c7Claude37import healthRoutes from "./routes/health-probe";
38import healthDashboardRoutes from "./routes/health";
2316be6Claude39import statusRoutes from "./routes/status";
b1be050CC LABS App40import adminStatusRoutes from "./routes/admin-status";
80bed05Claude41import helpRoutes from "./routes/help";
b0148e9Claude42import marketingRoutes from "./routes/marketing";
5f2e749Claude43import pricingRoutes from "./routes/pricing";
5618f9aClaude44import seoRoutes from "./routes/seo";
05cdb85Claude45import versionRoutes from "./routes/version";
f295f78Dictation App46import { platformStatus } from "./routes/platform-status";
52ad8b1Claude47import publicStatsRoutes from "./routes/public-stats";
48import demoRoutes from "./routes/demo";
16b325cClaude49import insightRoutes from "./routes/insights";
f1ab587Claude50import dashboardRoutes from "./routes/dashboard";
36b4cbdClaude51import legalRoutes from "./routes/legal";
4b66018Claude52import legalDmcaRoutes from "./routes/legal/dmca";
53import legalTermsRoutes from "./routes/legal/terms";
54import legalPrivacyRoutes from "./routes/legal/privacy";
55import legalAcceptableUseRoutes from "./routes/legal/acceptable-use";
bdbd0deClaude56import importRoutes from "./routes/import";
14c3cc8Claude57import importBulkRoutes from "./routes/import-bulk";
f390cfaCC LABS App58import importSecretsRoutes from "./routes/import-secrets";
14c3cc8Claude59import migrationRoutes from "./routes/migrations";
60import specsRoutes from "./routes/specs";
79136bbClaude61import webRoutes from "./routes/web";
0316dbbClaude62import hookRoutes from "./routes/hooks";
63import eventsRoutes from "./routes/events";
64import passkeyRoutes from "./routes/passkeys";
65import oauthRoutes from "./routes/oauth";
66import developerAppsRoutes from "./routes/developer-apps";
67import themeRoutes from "./routes/theme";
68import auditRoutes from "./routes/audit";
69import reactionRoutes from "./routes/reactions";
70import savedReplyRoutes from "./routes/saved-replies";
71import deploymentRoutes from "./routes/deployments";
72import orgRoutes from "./routes/orgs";
73import notificationRoutes from "./routes/notifications";
74import onboardingRoutes from "./routes/onboarding";
75import adminRoutes from "./routes/admin";
f764c07Claude76import adminDeploysRoutes from "./routes/admin-deploys";
77import adminDeploysPageRoutes from "./routes/admin-deploys-page";
9dd96b9Test User78import adminOpsRoutes from "./routes/admin-ops";
f2c00b4CC LABS App79import adminSelfHostRoutes from "./routes/admin-self-host";
826eccfTest User80import adminDiagnoseRoutes from "./routes/admin-diagnose";
509c376Claude81import adminIntegrationsRoutes from "./routes/admin-integrations";
0316dbbClaude82import advisoriesRoutes from "./routes/advisories";
83import aiChangelogRoutes from "./routes/ai-changelog";
84import aiExplainRoutes from "./routes/ai-explain";
85import aiTestsRoutes from "./routes/ai-tests";
86import askRoutes from "./routes/ask";
87import billingRoutes from "./routes/billing";
6778ad2Claude88import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude89import codeScanningRoutes from "./routes/code-scanning";
90import commitStatusesRoutes from "./routes/commit-statuses";
91import copilotRoutes from "./routes/copilot";
92import depUpdaterRoutes from "./routes/dep-updater";
93import depsRoutes from "./routes/deps";
94import discussionsRoutes from "./routes/discussions";
95import environmentsRoutes from "./routes/environments";
96import followsRoutes from "./routes/follows";
97import gatesRoutes from "./routes/gates";
98import gistsRoutes from "./routes/gists";
99import graphqlRoutes from "./routes/graphql";
2c2163eClaude100import mcpRoutes from "./routes/mcp";
0316dbbClaude101import marketplaceRoutes from "./routes/marketplace";
102import mergeQueueRoutes from "./routes/merge-queue";
103import mirrorsRoutes from "./routes/mirrors";
104import orgInsightsRoutes from "./routes/org-insights";
105import packagesRoutes from "./routes/packages";
106import packagesApiRoutes from "./routes/packages-api";
107import pagesRoutes from "./routes/pages";
108import projectsRoutes from "./routes/projects";
109import protectedTagsRoutes from "./routes/protected-tags";
110import pwaRoutes from "./routes/pwa";
46d6165Claude111import installRoutes from "./routes/install";
cd4f63bTest User112import dxtRoutes from "./routes/dxt";
662ce86Claude113import connectClaudeRoutes from "./routes/connect-claude";
0316dbbClaude114import releasesRoutes from "./routes/releases";
115import requiredChecksRoutes from "./routes/required-checks";
116import rulesetsRoutes from "./routes/rulesets";
117import searchRoutes from "./routes/search";
118import semanticSearchRoutes from "./routes/semantic-search";
119import signingKeysRoutes from "./routes/signing-keys";
120import sponsorsRoutes from "./routes/sponsors";
121import ssoRoutes from "./routes/sso";
46d6165Claude122import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude123import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude124import symbolsRoutes from "./routes/symbols";
125import templatesRoutes from "./routes/templates";
126import trafficRoutes from "./routes/traffic";
127import wikisRoutes from "./routes/wikis";
128import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude129import workflowArtifactsRoutes from "./routes/workflow-artifacts";
130import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude131import sleepModeRoutes from "./routes/sleep-mode";
52ad8b1Claude132import vsGithubRoutes from "./routes/vs-github";
cd4f63bTest User133import playgroundRoutes from "./routes/playground";
59b6fb2Claude134import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
135import { csrfToken, csrfProtect } from "./middleware/csrf";
79136bbClaude136
2316901Claude137import type { AuthEnv } from "./middleware/auth";
bf19c50Test User138import { softAuth } from "./middleware/auth";
2316901Claude139
140const app = new Hono<AuthEnv>();
79136bbClaude141
3ef4c9dClaude142// Request context (request ID, start time) runs before everything else
143app.use("*", requestContext);
05b973eClaude144// Middleware — compression first (wraps all responses)
145app.use("*", compress());
f1ffd50Claude146
147// ETag middleware — returns 304 Not Modified on unchanged responses.
148// Saves ~95% bandwidth on repeat visits. Skipped on git protocol +
149// SSE + the API surface where it would interfere with streaming.
150app.use("*", async (c, next) => {
151 const p = c.req.path;
152 if (
153 p.includes(".git/") ||
154 p.startsWith("/live-events") ||
155 p.startsWith("/api/events/deploy") ||
156 p.startsWith("/admin/status")
157 ) {
158 return next();
159 }
160 return etag()(c, next);
161});
162
163// Cache-Control middleware — sets sensible defaults on public, anonymous
164// requests. Crontech (when wired as our edge layer) and downstream
165// browsers will honor these. Auth'd users get private,no-store
166// automatically — we never cache responses tied to a session.
167app.use("*", async (c, next) => {
168 await next();
169 // Don't overwrite explicit headers set by route handlers — BUT the
170 // ETag middleware unconditionally sets "private, no-cache, must-
171 // revalidate" so we have to treat that specific value as "no
172 // policy chosen yet" and apply ours. Any route that explicitly set
173 // a different cache-control wins.
174 const existing = c.res.headers.get("cache-control");
175 const etagDefault =
176 existing === "private, no-cache, must-revalidate" ||
177 existing === "no-cache";
178 if (existing && !etagDefault) return;
179 // Anything past auth: private + no-store (avoid leaking session
180 // content into shared caches). softAuth runs before this on the
181 // request, but the response side is what we're stamping.
182 const hasSession = c.req.header("cookie")?.includes("session=") ?? false;
183 const p = c.req.path;
184 // Always private for known-authed paths regardless of cookie.
185 if (
186 p.startsWith("/admin") ||
187 p.startsWith("/settings") ||
188 p.startsWith("/dashboard") ||
189 p.startsWith("/notifications") ||
190 p.startsWith("/connect/") ||
191 hasSession
192 ) {
193 c.res.headers.set("cache-control", "private, no-store");
194 return;
195 }
196 // Public marketing surfaces — short edge cache, longer browser cache,
197 // stale-while-revalidate so the user never waits on a stale fetch.
198 const isMarketing =
199 p === "/" ||
200 p === "/features" ||
201 p === "/pricing" ||
202 p === "/about" ||
203 p === "/vs-github" ||
204 p === "/explore" ||
205 p === "/help" ||
206 p === "/changelog" ||
207 p.startsWith("/legal/") ||
208 p === "/terms" ||
209 p === "/privacy" ||
210 p === "/acceptable-use" ||
211 p.startsWith("/docs/");
212 if (isMarketing) {
213 c.res.headers.set(
214 "cache-control",
215 "public, max-age=60, s-maxage=300, stale-while-revalidate=86400"
216 );
217 return;
218 }
219 // Public repo browse pages — cache aggressively. Edge invalidates
220 // on push via the post-receive hook (future Crontech surge purge).
221 if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") {
222 c.res.headers.set(
223 "cache-control",
224 "public, max-age=30, s-maxage=120, stale-while-revalidate=600"
225 );
226 return;
227 }
228 // Default: don't cache anything we haven't explicitly opted in.
229 c.res.headers.set("cache-control", "private, no-store");
230});
05b973eClaude231// Logger only on non-git routes to avoid overhead on clone/push
232app.use("*", async (c, next) => {
233 if (c.req.path.includes(".git/")) return next();
234 return logger()(c, next);
235});
79136bbClaude236app.use("/api/*", cors());
bf19c50Test User237// Global softAuth — populates c.get("user") for every downstream middleware
238// + route. This was previously per-route, which meant rate-limit middleware
239// (and anything else inspecting auth state) always saw a null user. Keep
240// individual routes free to add requireAuth on top for hard gating; this
241// just establishes the user object cheaply.
242app.use("*", softAuth);
290ea77Claude243
36cc17aClaude244// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude245// pre-redesign markup. JSON / static assets keep their own cache rules; only
246// text/html responses get the no-cache stamp. Without this, every push to
247// main left users staring at cached 80s-looking pages from before the design
248// landed.
36cc17aClaude249//
250// We deliberately use `private, no-cache, must-revalidate` rather than
251// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
252// which makes every Back/Forward press a cold server round-trip — that
253// contributed to the "every nav feels like a fresh login" UX complaint.
254// `no-cache` still revalidates on direct fetch but lets bfcache hold the
255// page in memory between navigations.
290ea77Claude256app.use("*", async (c, next) => {
257 await next();
258 const ct = c.res.headers.get("content-type") || "";
259 if (ct.startsWith("text/html")) {
36cc17aClaude260 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude261 }
262});
826eccfTest User263// Rate-limit API + auth endpoints.
264//
a41e675Test User265// `/api/*`: 1000/min per IP — generous so an admin clicking around the
266// operator console (or a CDN/proxy concentrating multiple users behind one
267// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
268// rate limits below, not this one.
269//
270// `authedMultiplier` is set but only fires when an upstream middleware has
271// already populated c.get("user") — most app.use() chains apply softAuth
272// per-route, so the multiplier is best-effort. Keep the anonymous base
273// high enough that humans never feel it.
274//
275// Skip-paths: dashboard plumbing endpoints that the layout polls on a
276// fixed cadence and that we don't want consuming any bucket:
277// /api/version — layout polls every 15s
826eccfTest User278// /api/notifications/count — nav bell unread-count fetcher
279// /pwa/vapid-public-key — fetched once per push-notification opt-in
280app.use(
281 "/api/*",
a41e675Test User282 rateLimit(1000, 60_000, "api", {
826eccfTest User283 authedMultiplier: 4,
284 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
285 })
286);
0316dbbClaude287app.use("/login", rateLimit(20, 60_000, "login"));
288app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude289// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
290app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User291// BLOCK Q2 — throttle magic-link sign-in for the same reason.
292app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude293
59b6fb2Claude294// CSRF protection — set token on all requests, validate on mutations
295app.use("*", csrfToken);
296app.use("*", csrfProtect);
297
45e31d0Claude298// Rate limit auth routes
299app.use("/login", authRateLimit);
300app.use("/register", authRateLimit);
301
59b6fb2Claude302// Rate limit git operations
303app.use("/:owner/:repo.git/*", gitRateLimit);
304
305// Rate limit search
306app.use("/:owner/:repo/search", searchRateLimit);
307app.use("/explore", searchRateLimit);
79136bbClaude308
309// Git Smart HTTP protocol routes (must be before web routes)
310app.route("/", gitRoutes);
311
45e31d0Claude312// REST API v1 (legacy)
79136bbClaude313app.route("/", apiRoutes);
314
52ad8b1Claude315// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
316// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
317// router's catch-shape, and BEFORE adminRoutes so the live /demo page
318// wins over the legacy /demo redirect in src/routes/admin.tsx.
319app.route("/", demoRoutes);
320
0316dbbClaude321// REST API v2 (basePath /api/v2)
322app.route("/", apiV2Routes);
323
ad6d4adClaude324// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
325app.route("/", hookRoutes);
21f8dbdClaude326app.route("/api/events", eventsRoutes);
ad6d4adClaude327
45e31d0Claude328// API documentation
329app.route("/", apiDocsRoutes);
4a80519Claude330app.route("/", buildAgentSpecRoutes);
a6ff0f2Claude331// PR command center — global PR dashboard with AI/GateTest/auto-merge signal
332app.route("/", pullsDashboardRoutes);
79136bbClaude333
334// Auth routes (register, login, logout)
335app.route("/", authRoutes);
336
c63b860Claude337// BLOCK P1 — Password reset (forgot-password + reset-password)
338app.route("/", passwordResetRoutes);
339
340// BLOCK P2 — Email verification (verify-email + resend)
341app.route("/", emailVerificationRoutes);
342
cd4f63bTest User343// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
344app.route("/", magicLinkRoutes);
345
79136bbClaude346// Settings routes (profile, SSH keys)
347app.route("/", settingsRoutes);
348
7298a17Claude349// 2FA / TOTP settings (Block B4)
350app.route("/", settings2faRoutes);
351
2df1f8cClaude352// WebAuthn / passkey routes (Block B5)
353app.route("/", passkeyRoutes);
354
058d752Claude355// OAuth 2.0 provider (Block B6)
356app.route("/", oauthRoutes);
357app.route("/", developerAppsRoutes);
358
6fc53bdClaude359// Theme toggle (dark/light cookie)
360app.route("/", themeRoutes);
361
362// Audit log UI
363app.route("/", auditRoutes);
364
365// Reactions API (issues, PRs, comments)
366app.route("/", reactionRoutes);
367
24cf2caClaude368// Saved replies (per-user canned comment templates)
369app.route("/", savedReplyRoutes);
370
371// Environments + deployment history UI
372app.route("/", deploymentRoutes);
373
6563f0aClaude374// Organizations + teams (Block B1)
375app.route("/", orgRoutes);
376
c81ab7aClaude377// API tokens
378app.route("/", tokenRoutes);
379
59b6fb2Claude380// Notifications
3ef4c9dClaude381app.route("/", notificationRoutes);
382
79136bbClaude383// Repo settings (description, visibility, delete)
384app.route("/", repoSettings);
385
23d1a81Claude386// Repo collaborators (add/list/remove)
387app.route("/", collaboratorRoutes);
388
04f6b7fClaude389// Team-based repo collaborators (invite a whole team)
390app.route("/", teamCollaboratorRoutes);
391
392// Collaborator invite accept flow (token-based)
393app.route("/", invitesRoutes);
394
395// Real-time SSE endpoint (topic-based live updates)
396app.route("/", liveEventsRoutes);
397
c81ab7aClaude398// Webhooks management
399app.route("/", webhookRoutes);
400
79136bbClaude401// Compare view (branch diffs)
402app.route("/", compareRoutes);
403
404// Issue tracker
405app.route("/", issueRoutes);
406
0074234Claude407// Pull requests
408app.route("/", pullRoutes);
409
c81ab7aClaude410// Fork
411app.route("/", forkRoutes);
412
0074234Claude413// Web file editor
414app.route("/", editorRoutes);
415
43de941Claude416// Contributors
417app.route("/", contributorRoutes);
418
699e5c7Claude419// Health liveness + metrics endpoints
2c34075Claude420app.route("/", healthRoutes);
421
f295f78Dictation App422// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
423app.route("/api/platform-status", platformStatus);
424
52ad8b1Claude425// Block L4 — Public stats counters (powers landing-page social proof)
426app.route("/", publicStatsRoutes);
427
428// Block L3 — Live /demo page + /api/v2/demo/* endpoints
429app.route("/", demoRoutes);
430
2316be6Claude431// Public /status — human-readable platform health page
432app.route("/", statusRoutes);
433
b1be050CC LABS App434// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
435// Mounted near the public status route so the two surfaces are visible
436// side-by-side; routes are gated by isSiteAdmin internally.
437app.route("/", adminStatusRoutes);
438
80bed05Claude439// /help — quickstart + API cheatsheet
440app.route("/", helpRoutes);
441
5f2e749Claude442// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
443// so the new editorial pricing layout wins the route; the legacy marketing
444// pricing remains as a safety net but is shadowed at the router.
445app.route("/", pricingRoutes);
446
b0148e9Claude447// /pricing, /features, /about — marketing surface
448app.route("/", marketingRoutes);
449
5618f9aClaude450// SEO: robots.txt + sitemap.xml
451app.route("/", seoRoutes);
452
05cdb85Claude453// /api/version — live build SHA + uptime; client poller uses this to
454// surface 'New version available — reload' banners on deploy.
455app.route("/", versionRoutes);
456
699e5c7Claude457// Health dashboard (per-repo health page)
458app.route("/", healthDashboardRoutes);
459
9dd96b9Test User460// Block R1 — site-admin operations console. MUST be mounted BEFORE
461// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
462// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
463app.route("/", adminOpsRoutes);
f2c00b4CC LABS App464// BLOCK W — Self-host status + bootstrap dashboard.
465app.route("/", adminSelfHostRoutes);
826eccfTest User466// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
467app.route("/", adminDiagnoseRoutes);
9dd96b9Test User468
16b325cClaude469// Insights (time-travel, dependencies, rollback)
470app.route("/", insightRoutes);
471
f1ab587Claude472// Command center dashboard
473app.route("/", dashboardRoutes);
474
36b4cbdClaude475// Legal pages (terms, privacy, AUP)
476app.route("/", legalRoutes);
4b66018Claude477// Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}.
478// The main `legal.tsx` serves the short canonical paths (/terms, /privacy,
479// /acceptable-use); these are the formal versions that the legal pages
480// internally link to each other.
481app.route("/", legalTermsRoutes);
482app.route("/", legalPrivacyRoutes);
483app.route("/", legalAcceptableUseRoutes);
484app.route("/", legalDmcaRoutes);
36b4cbdClaude485
bdbd0deClaude486// GitHub import / migration
487app.route("/", importRoutes);
14c3cc8Claude488app.route("/", importBulkRoutes);
f390cfaCC LABS App489app.route("/", importSecretsRoutes);
14c3cc8Claude490app.route("/", migrationRoutes);
491
492// Spec-to-PR (experimental AI-generated draft PRs)
493app.route("/", specsRoutes);
bdbd0deClaude494
c81ab7aClaude495// Explore page
496app.route("/", exploreRoutes);
497
59b6fb2Claude498// Onboarding
499app.route("/", onboardingRoutes);
500
0316dbbClaude501// Admin + feature routes
502app.route("/", adminRoutes);
509c376Claude503app.route("/", adminIntegrationsRoutes);
f764c07Claude504app.route("/", adminDeploysRoutes);
505app.route("/", adminDeploysPageRoutes);
9dd96b9Test User506// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude507app.route("/", advisoriesRoutes);
508app.route("/", aiChangelogRoutes);
509app.route("/", aiExplainRoutes);
510app.route("/", aiTestsRoutes);
511app.route("/", askRoutes);
512app.route("/", billingRoutes);
6778ad2Claude513app.route("/", stripeWebhookRoutes);
0316dbbClaude514app.route("/", codeScanningRoutes);
515app.route("/", commitStatusesRoutes);
516app.route("/", copilotRoutes);
517app.route("/", depUpdaterRoutes);
518app.route("/", depsRoutes);
519app.route("/", discussionsRoutes);
520app.route("/", environmentsRoutes);
521app.route("/", followsRoutes);
522app.route("/", gatesRoutes);
523app.route("/", gistsRoutes);
524app.route("/", graphqlRoutes);
2c2163eClaude525app.route("/", mcpRoutes);
0316dbbClaude526app.route("/", marketplaceRoutes);
527app.route("/", mergeQueueRoutes);
528app.route("/", mirrorsRoutes);
529app.route("/", orgInsightsRoutes);
530app.route("/", packagesRoutes);
531app.route("/", packagesApiRoutes);
532app.route("/", pagesRoutes);
533app.route("/", projectsRoutes);
534app.route("/", protectedTagsRoutes);
535app.route("/", pwaRoutes);
46d6165Claude536app.route("/", installRoutes);
cd4f63bTest User537// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
538app.route("/", dxtRoutes);
662ce86Claude539// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
540// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
541app.route("/", connectClaudeRoutes);
0316dbbClaude542app.route("/", releasesRoutes);
543app.route("/", requiredChecksRoutes);
544app.route("/", rulesetsRoutes);
545app.route("/", searchRoutes);
546app.route("/", semanticSearchRoutes);
547app.route("/", signingKeysRoutes);
548app.route("/", sponsorsRoutes);
549app.route("/", ssoRoutes);
46d6165Claude550app.route("/", githubOauthRoutes);
582cdacClaude551app.route("/", googleOauthRoutes);
0316dbbClaude552app.route("/", symbolsRoutes);
553app.route("/", templatesRoutes);
554app.route("/", trafficRoutes);
555app.route("/", wikisRoutes);
556app.route("/", workflowsRoutes);
5ff9cc2Claude557app.route("/", workflowArtifactsRoutes);
558app.route("/", workflowSecretsRoutes);
46d6165Claude559app.route("/", sleepModeRoutes);
52ad8b1Claude560app.route("/", vsGithubRoutes);
0316dbbClaude561
cd4f63bTest User562// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
563// before the web catch-all so the bare `/play` literal wins over the
564// `/:owner` user-profile route.
565app.route("/", playgroundRoutes);
566
79136bbClaude567// Web UI (catch-all, must be last)
568app.route("/", webRoutes);
569
c63b860Claude570// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
571// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude572app.notFound((c) => {
36cc17aClaude573 const user = c.get("user") ?? null;
79136bbClaude574 return c.html(
c63b860Claude575 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude576 404
577 );
578});
579
c63b860Claude580// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
581// view. Trace block only shown outside production.
79136bbClaude582app.onError((err, c) => {
80bed05Claude583 reportError(err, {
584 requestId: c.get("requestId"),
585 path: c.req.path,
586 method: c.req.method,
587 });
c63b860Claude588 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
589 // back to the context value set by request-context middleware.
590 const requestId =
591 c.req.header("x-request-id") ||
592 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude593 const user = c.get("user") ?? null;
c63b860Claude594 const trace =
595 process.env.NODE_ENV !== "production" && err && err.message
596 ? err.message
597 : undefined;
79136bbClaude598 return c.html(
c63b860Claude599 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude600 500
601 );
602});
603
604export default app;