Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
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.tsxBlame950 lines · 6 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";
cc34156Claude19import digestRoutes from "./routes/digest";
e9aa4d8Claude20import activityRoutes from "./routes/activity";
79136bbClaude21import authRoutes from "./routes/auth";
c63b860Claude22import passwordResetRoutes from "./routes/password-reset";
23import emailVerificationRoutes from "./routes/email-verification";
cd4f63bTest User24import magicLinkRoutes from "./routes/magic-link";
79136bbClaude25import settingsRoutes from "./routes/settings";
7298a17Claude26import settings2faRoutes from "./routes/settings-2fa";
e75eddcClaude27import settingsAgentsRoutes from "./routes/settings-agents";
1d4ff60Claude28import settingsIntegrationsRoutes from "./routes/settings-integrations";
29import integrationsChatRoutes from "./routes/integrations-chat";
e75eddcClaude30import agentsRoutes from "./routes/agents";
ef3fd93Claude31import agentPipelinesRoutes from "./routes/agent-pipelines";
79136bbClaude32import issueRoutes from "./routes/issues";
85c4e13Claude33import milestonesRoutes from "./routes/milestones";
f928118Claude34import shipAgentRoutes from "./routes/ship-agent";
cb5a796Claude35import commentModerationRoutes from "./routes/comment-moderation";
79136bbClaude36import repoSettings from "./routes/repo-settings";
479dcd9Claude37import automationSettingsRoutes from "./routes/automation-settings";
23d1a81Claude38import collaboratorRoutes from "./routes/collaborators";
04f6b7fClaude39import teamCollaboratorRoutes from "./routes/team-collaborators";
40import invitesRoutes from "./routes/invites";
41import liveEventsRoutes from "./routes/live-events";
3c03977Claude42import prLiveRoutes from "./routes/pr-live";
79136bbClaude43import compareRoutes from "./routes/compare";
0074234Claude44import pullRoutes from "./routes/pulls";
79ed944Claude45import prSandboxRoutes from "./routes/pr-sandbox";
9b3a183Claude46import devEnvRoutes from "./routes/dev-env";
0074234Claude47import editorRoutes from "./routes/editor";
6f2809fClaude48import aiEditorRoutes from "./routes/ai-editor";
c81ab7aClaude49import forkRoutes from "./routes/fork";
50import webhookRoutes from "./routes/webhooks";
51import exploreRoutes from "./routes/explore";
52import tokenRoutes from "./routes/tokens";
43de941Claude53import contributorRoutes from "./routes/contributors";
699e5c7Claude54import healthRoutes from "./routes/health-probe";
55import healthDashboardRoutes from "./routes/health";
2316be6Claude56import statusRoutes from "./routes/status";
b1be050CC LABS App57import adminStatusRoutes from "./routes/admin-status";
80bed05Claude58import helpRoutes from "./routes/help";
e1fc7dbClaude59import changelogRoutes from "./routes/changelog";
e0e4219Claude60import docsRoutes from "./routes/docs";
b0148e9Claude61import marketingRoutes from "./routes/marketing";
5f2e749Claude62import pricingRoutes from "./routes/pricing";
9f29b65Claude63import enterpriseRoutes from "./routes/enterprise";
5618f9aClaude64import seoRoutes from "./routes/seo";
05cdb85Claude65import versionRoutes from "./routes/version";
f295f78Dictation App66import { platformStatus } from "./routes/platform-status";
52ad8b1Claude67import publicStatsRoutes from "./routes/public-stats";
68import demoRoutes from "./routes/demo";
16b325cClaude69import insightRoutes from "./routes/insights";
8286942Claude70import engineeringInsightsRoutes from "./routes/engineering-insights";
8d1483cClaude71import doraRoutes from "./routes/dora";
f1ab587Claude72import dashboardRoutes from "./routes/dashboard";
36b4cbdClaude73import legalRoutes from "./routes/legal";
4b66018Claude74import legalDmcaRoutes from "./routes/legal/dmca";
75import legalTermsRoutes from "./routes/legal/terms";
76import legalPrivacyRoutes from "./routes/legal/privacy";
77import legalAcceptableUseRoutes from "./routes/legal/acceptable-use";
bdbd0deClaude78import importRoutes from "./routes/import";
14c3cc8Claude79import importBulkRoutes from "./routes/import-bulk";
f390cfaCC LABS App80import importSecretsRoutes from "./routes/import-secrets";
bb2dea9Claude81import actionsImporterRoutes from "./routes/actions-importer";
14c3cc8Claude82import migrationRoutes from "./routes/migrations";
ba23fe2Claude83import migrationAssistantRoutes from "./routes/migration-assistant";
9a8b8deClaude84import migrateRoutes from "./routes/migrate";
14c3cc8Claude85import specsRoutes from "./routes/specs";
23d0abfClaude86import refactorRoutes from "./routes/refactors";
b665cacClaude87import codebaseMigratorRoutes from "./routes/codebase-migrator";
79136bbClaude88import webRoutes from "./routes/web";
0316dbbClaude89import hookRoutes from "./routes/hooks";
90import eventsRoutes from "./routes/events";
91import passkeyRoutes from "./routes/passkeys";
92import oauthRoutes from "./routes/oauth";
369ad65ccanty labs93import wellKnownRoutes from "./routes/well-known";
0316dbbClaude94import developerAppsRoutes from "./routes/developer-apps";
95import themeRoutes from "./routes/theme";
96import auditRoutes from "./routes/audit";
97import reactionRoutes from "./routes/reactions";
98import savedReplyRoutes from "./routes/saved-replies";
99import deploymentRoutes from "./routes/deployments";
2c61840Claude100import pipelineRoutes from "./routes/pipeline";
0316dbbClaude101import orgRoutes from "./routes/orgs";
102import notificationRoutes from "./routes/notifications";
103import onboardingRoutes from "./routes/onboarding";
104import adminRoutes from "./routes/admin";
7293c67Claude105import adminDeletionsRoutes from "./routes/admin-deletions";
106import adminStripeRoutes from "./routes/admin-stripe";
f764c07Claude107import adminDeploysRoutes from "./routes/admin-deploys";
108import adminDeploysPageRoutes from "./routes/admin-deploys-page";
783dd46Claude109import adminServerTargetsRoutes from "./routes/admin-server-targets";
9aaa128Claude110import deployTargetsRoutes from "./routes/deploy-targets";
90c7531Claude111import claudeWebRoutes from "./routes/claude-web";
9dd96b9Test User112import adminOpsRoutes from "./routes/admin-ops";
f2c00b4CC LABS App113import adminSelfHostRoutes from "./routes/admin-self-host";
826eccfTest User114import adminDiagnoseRoutes from "./routes/admin-diagnose";
f9814d2Claude115import adminCommandRoutes from "./routes/admin-command";
509c376Claude116import adminIntegrationsRoutes from "./routes/admin-integrations";
bc519aeClaude117import adminEnvHealthRoutes from "./routes/admin-env-health";
79ed944Claude118import adminAdvancementRoutes from "./routes/admin-advancement";
ba9e143Claude119import adminSecurityRoutes from "./routes/admin-security";
120import settingsSessionsRoutes from "./routes/settings-sessions";
0316dbbClaude121import advisoriesRoutes from "./routes/advisories";
122import aiChangelogRoutes from "./routes/ai-changelog";
0a69faaClaude123import explainRoutes from "./routes/explain";
0316dbbClaude124import aiExplainRoutes from "./routes/ai-explain";
2be65d0Claude125import archaeologyRoutes from "./routes/ai-archaeology";
0316dbbClaude126import aiTestsRoutes from "./routes/ai-tests";
127import askRoutes from "./routes/ask";
38d31d3Claude128import repoChatRoutes from "./routes/repo-chat";
ee7e577Claude129import personalChatRoutes from "./routes/personal-chat";
0316dbbClaude130import billingRoutes from "./routes/billing";
8809b87Claude131import billingUsageRoutes from "./routes/billing-usage";
6778ad2Claude132import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude133import codeScanningRoutes from "./routes/code-scanning";
da3fc18Claude134import securityRoutes from "./routes/security";
0316dbbClaude135import commitStatusesRoutes from "./routes/commit-statuses";
136import copilotRoutes from "./routes/copilot";
f5d020fClaude137import { pairProgrammerRoutes } from "./routes/pair-programmer";
0316dbbClaude138import depUpdaterRoutes from "./routes/dep-updater";
139import depsRoutes from "./routes/deps";
140import discussionsRoutes from "./routes/discussions";
141import environmentsRoutes from "./routes/environments";
4bbacbeClaude142import previewsRoutes from "./routes/previews";
79ed944Claude143import docsTrackingRoutes from "./routes/docs-tracking";
0316dbbClaude144import followsRoutes from "./routes/follows";
145import gatesRoutes from "./routes/gates";
146import gistsRoutes from "./routes/gists";
147import graphqlRoutes from "./routes/graphql";
2c2163eClaude148import mcpRoutes from "./routes/mcp";
0316dbbClaude149import marketplaceRoutes from "./routes/marketplace";
5ca514aClaude150import marketplaceAgentsRoutes from "./routes/marketplace-agents";
0316dbbClaude151import mergeQueueRoutes from "./routes/merge-queue";
152import mirrorsRoutes from "./routes/mirrors";
153import orgInsightsRoutes from "./routes/org-insights";
2be65d0Claude154import orgHealthRoutes from "./routes/org-health";
0316dbbClaude155import packagesRoutes from "./routes/packages";
156import packagesApiRoutes from "./routes/packages-api";
845fd8aClaude157import ociRegistryRoutes from "./routes/oci-registry";
0316dbbClaude158import pagesRoutes from "./routes/pages";
159import projectsRoutes from "./routes/projects";
160import protectedTagsRoutes from "./routes/protected-tags";
161import pwaRoutes from "./routes/pwa";
46d6165Claude162import installRoutes from "./routes/install";
cd4f63bTest User163import dxtRoutes from "./routes/dxt";
662ce86Claude164import connectClaudeRoutes from "./routes/connect-claude";
ebbb527Claude165import claudeDeployRoutes from "./routes/claude-deploy";
f5b9ef5Claude166import claudeIntegration from "./routes/claude-integration";
167import connectRoutes from "./routes/connect";
05ab9b1Claude168import pushWatchRoutes from "./routes/push-watch";
169import orgSecretsRoutes from "./routes/org-secrets";
0316dbbClaude170import releasesRoutes from "./routes/releases";
171import requiredChecksRoutes from "./routes/required-checks";
172import rulesetsRoutes from "./routes/rulesets";
173import searchRoutes from "./routes/search";
174import semanticSearchRoutes from "./routes/semantic-search";
77cf834Claude175import nlSearchRoutes from "./routes/nl-search";
0316dbbClaude176import signingKeysRoutes from "./routes/signing-keys";
177import sponsorsRoutes from "./routes/sponsors";
178import ssoRoutes from "./routes/sso";
3a845e4Claude179import samlSsoRoutes from "./routes/saml-sso";
180import scimRoutes from "./routes/scim";
181import orgSsoSettingsRoutes from "./routes/org-sso-settings";
46d6165Claude182import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude183import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude184import symbolsRoutes from "./routes/symbols";
185import templatesRoutes from "./routes/templates";
186import trafficRoutes from "./routes/traffic";
187import wikisRoutes from "./routes/wikis";
188import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude189import workflowArtifactsRoutes from "./routes/workflow-artifacts";
190import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude191import sleepModeRoutes from "./routes/sleep-mode";
56801e1Claude192import standupRoutes from "./routes/standups";
52ad8b1Claude193import vsGithubRoutes from "./routes/vs-github";
45f3b73Claude194import voiceRoutes from "./routes/voice-to-pr";
3122762Claude195import blogRoutes from "./routes/blog";
cd4f63bTest User196import playgroundRoutes from "./routes/playground";
a2b3e99Claude197import crossRepoSearchRoutes from "./routes/cross-repo-search";
198import pushNotifRoutes from "./routes/push-notifications";
9fbe6cdClaude199import velocityRoutes from "./routes/velocity";
200import { staleBranchRoutes } from "./routes/stale-branches";
22f43f3Claude201import pulseRoutes from "./routes/pulse";
74d8c4dClaude202import healthScoreRoutes from "./routes/health-score";
77cf834Claude203import repoHealthRoutes from "./routes/repo-health";
74d8c4dClaude204import hotFilesRoutes from "./routes/hot-files";
bcc4020Claude205import debtMapRoutes from "./routes/debt-map";
1d6db4dClaude206import busFactorRoutes from "./routes/bus-factor";
2be65d0Claude207import testGapsRoutes from "./routes/test-gaps";
f5d020fClaude208import crossRepoImpactRoutes from "./routes/cross-repo-impact";
adf5e18Claude209import developerProgramRoutes from "./routes/developer-program";
891efbeClaude210import shareRoutes from "./routes/share";
70e3293Claude211import incidentHookRoutes from "./routes/incident-hooks";
77cf834Claude212import workspaceRoutes from "./routes/ai-workspace";
2c61840Claude213import workspaceHubRoutes from "./routes/workspace-hub";
4d4bd4bccantynz-alt214import { apiRateLimit, authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
59b6fb2Claude215import { csrfToken, csrfProtect } from "./middleware/csrf";
f5b9ef5Claude216import { noCache } from "./middleware/no-cache";
79136bbClaude217
2316901Claude218import type { AuthEnv } from "./middleware/auth";
bf19c50Test User219import { softAuth } from "./middleware/auth";
2316901Claude220
221const app = new Hono<AuthEnv>();
79136bbClaude222
3ef4c9dClaude223// Request context (request ID, start time) runs before everything else
224app.use("*", requestContext);
05b973eClaude225// Middleware — compression first (wraps all responses)
226app.use("*", compress());
f1ffd50Claude227
228// ETag middleware — returns 304 Not Modified on unchanged responses.
229// Saves ~95% bandwidth on repeat visits. Skipped on git protocol +
230// SSE + the API surface where it would interfere with streaming.
231app.use("*", async (c, next) => {
232 const p = c.req.path;
233 if (
234 p.includes(".git/") ||
235 p.startsWith("/live-events") ||
236 p.startsWith("/api/events/deploy") ||
3c03977Claude237 p.startsWith("/admin/status") ||
238 // PR live co-editing SSE stream — never etag streaming responses.
239 /^\/api\/v2\/pulls\/[^/]+\/live(\/|$)/.test(p)
f1ffd50Claude240 ) {
241 return next();
242 }
243 return etag()(c, next);
244});
245
246// Cache-Control middleware — sets sensible defaults on public, anonymous
9ecf5a4Claude247// requests. Vapron (when wired as our edge layer) and downstream
f1ffd50Claude248// browsers will honor these. Auth'd users get private,no-store
249// automatically — we never cache responses tied to a session.
250app.use("*", async (c, next) => {
251 await next();
252 // Don't overwrite explicit headers set by route handlers — BUT the
253 // ETag middleware unconditionally sets "private, no-cache, must-
254 // revalidate" so we have to treat that specific value as "no
255 // policy chosen yet" and apply ours. Any route that explicitly set
256 // a different cache-control wins.
257 const existing = c.res.headers.get("cache-control");
258 const etagDefault =
259 existing === "private, no-cache, must-revalidate" ||
260 existing === "no-cache";
261 if (existing && !etagDefault) return;
262 // Anything past auth: private + no-store (avoid leaking session
263 // content into shared caches). softAuth runs before this on the
264 // request, but the response side is what we're stamping.
265 const hasSession = c.req.header("cookie")?.includes("session=") ?? false;
266 const p = c.req.path;
267 // Always private for known-authed paths regardless of cookie.
268 if (
269 p.startsWith("/admin") ||
270 p.startsWith("/settings") ||
271 p.startsWith("/dashboard") ||
272 p.startsWith("/notifications") ||
273 p.startsWith("/connect/") ||
274 hasSession
275 ) {
276 c.res.headers.set("cache-control", "private, no-store");
277 return;
278 }
279 // Public marketing surfaces — short edge cache, longer browser cache,
280 // stale-while-revalidate so the user never waits on a stale fetch.
281 const isMarketing =
282 p === "/" ||
283 p === "/features" ||
284 p === "/pricing" ||
285 p === "/about" ||
286 p === "/vs-github" ||
287 p === "/explore" ||
288 p === "/help" ||
289 p === "/changelog" ||
9f29b65Claude290 p === "/enterprise" ||
f1ffd50Claude291 p.startsWith("/legal/") ||
292 p === "/terms" ||
293 p === "/privacy" ||
294 p === "/acceptable-use" ||
295 p.startsWith("/docs/");
296 if (isMarketing) {
297 c.res.headers.set(
298 "cache-control",
299 "public, max-age=60, s-maxage=300, stale-while-revalidate=86400"
300 );
301 return;
302 }
303 // Public repo browse pages — cache aggressively. Edge invalidates
9ecf5a4Claude304 // on push via the post-receive hook (future Vapron surge purge).
f1ffd50Claude305 if (/^\/[^/]+\/[^/]+(\/.*)?$/.test(p) && c.req.method === "GET") {
306 c.res.headers.set(
307 "cache-control",
308 "public, max-age=30, s-maxage=120, stale-while-revalidate=600"
309 );
310 return;
311 }
312 // Default: don't cache anything we haven't explicitly opted in.
313 c.res.headers.set("cache-control", "private, no-store");
314});
05b973eClaude315// Logger only on non-git routes to avoid overhead on clone/push
316app.use("*", async (c, next) => {
317 if (c.req.path.includes(".git/")) return next();
318 return logger()(c, next);
319});
79136bbClaude320app.use("/api/*", cors());
bf19c50Test User321// Global softAuth — populates c.get("user") for every downstream middleware
322// + route. This was previously per-route, which meant rate-limit middleware
323// (and anything else inspecting auth state) always saw a null user. Keep
324// individual routes free to add requireAuth on top for hard gating; this
325// just establishes the user object cheaply.
326app.use("*", softAuth);
290ea77Claude327
36cc17aClaude328// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude329// pre-redesign markup. JSON / static assets keep their own cache rules; only
330// text/html responses get the no-cache stamp. Without this, every push to
331// main left users staring at cached 80s-looking pages from before the design
332// landed.
36cc17aClaude333//
334// We deliberately use `private, no-cache, must-revalidate` rather than
335// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
336// which makes every Back/Forward press a cold server round-trip — that
337// contributed to the "every nav feels like a fresh login" UX complaint.
338// `no-cache` still revalidates on direct fetch but lets bfcache hold the
339// page in memory between navigations.
290ea77Claude340app.use("*", async (c, next) => {
341 await next();
342 const ct = c.res.headers.get("content-type") || "";
343 if (ct.startsWith("text/html")) {
36cc17aClaude344 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude345 }
346});
826eccfTest User347// Rate-limit API + auth endpoints.
348//
a41e675Test User349// `/api/*`: 1000/min per IP — generous so an admin clicking around the
350// operator console (or a CDN/proxy concentrating multiple users behind one
351// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
352// rate limits below, not this one.
353//
354// `authedMultiplier` is set but only fires when an upstream middleware has
355// already populated c.get("user") — most app.use() chains apply softAuth
356// per-route, so the multiplier is best-effort. Keep the anonymous base
357// high enough that humans never feel it.
358//
359// Skip-paths: dashboard plumbing endpoints that the layout polls on a
360// fixed cadence and that we don't want consuming any bucket:
361// /api/version — layout polls every 15s
826eccfTest User362// /api/notifications/count — nav bell unread-count fetcher
363// /pwa/vapid-public-key — fetched once per push-notification opt-in
364app.use(
365 "/api/*",
a41e675Test User366 rateLimit(1000, 60_000, "api", {
826eccfTest User367 authedMultiplier: 4,
368 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
369 })
370);
0316dbbClaude371app.use("/login", rateLimit(20, 60_000, "login"));
372app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude373// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
374app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User375// BLOCK Q2 — throttle magic-link sign-in for the same reason.
376app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude377
59b6fb2Claude378// CSRF protection — set token on all requests, validate on mutations
379app.use("*", csrfToken);
380app.use("*", csrfProtect);
381
45e31d0Claude382// Rate limit auth routes
383app.use("/login", authRateLimit);
384app.use("/register", authRateLimit);
385
59b6fb2Claude386// Rate limit git operations
387app.use("/:owner/:repo.git/*", gitRateLimit);
388
389// Rate limit search
390app.use("/:owner/:repo/search", searchRateLimit);
391app.use("/explore", searchRateLimit);
79136bbClaude392
4d4bd4bccantynz-alt393// Rate limit the v1 REST API and the MCP surface. api-v2 already applies its
394// own apiRateLimit internally (this stacks harmlessly for /api/v2/*); v1
395// (src/routes/api.ts) and /mcp had NO rate limiting at all despite /mcp
396// being the primary, anonymously-reachable AI-agent interface and able to
397// trigger expensive per-call work (e.g. gluecron_repo_health scans every
398// file in a repo). softAuth already runs on both, so the existing
399// authedMultiplier (4x for a signed-in caller) applies automatically.
400app.use("/api/*", apiRateLimit);
401app.use("/mcp", apiRateLimit);
402
f5b9ef5Claude403// No-cache for HTML — ensures browsers and proxies never serve stale pages.
404// The middleware only stamps text/html responses so static assets keep
405// their own cache policies unchanged.
406app.use("*", noCache);
407
79136bbClaude408// Git Smart HTTP protocol routes (must be before web routes)
409app.route("/", gitRoutes);
410
45e31d0Claude411// REST API v1 (legacy)
79136bbClaude412app.route("/", apiRoutes);
413
52ad8b1Claude414// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
415// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
416// router's catch-shape, and BEFORE adminRoutes so the live /demo page
417// wins over the legacy /demo redirect in src/routes/admin.tsx.
418app.route("/", demoRoutes);
419
0316dbbClaude420// REST API v2 (basePath /api/v2)
421app.route("/", apiV2Routes);
422
e75eddcClaude423// Agent multiplayer v1 — /api/v2/agents/* (sessions, leases, usage).
424// Mounted alongside apiV2Routes (its own basePath, no path conflict).
425app.route("/", agentsRoutes);
426
ef3fd93Claude427// Multi-agent pipeline UI — /:owner/:repo/agents (list, new, live view).
428// Must be before webRoutes (the catch-all) so the /agents sub-paths are
429// resolved before the generic tree/blob route takes over.
430app.route("/", agentPipelinesRoutes);
431
ad6d4adClaude432// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
433app.route("/", hookRoutes);
21f8dbdClaude434app.route("/api/events", eventsRoutes);
ad6d4adClaude435
45e31d0Claude436// API documentation
437app.route("/", apiDocsRoutes);
4a80519Claude438app.route("/", buildAgentSpecRoutes);
a6ff0f2Claude439// PR command center — global PR dashboard with AI/GateTest/auto-merge signal
440app.route("/", pullsDashboardRoutes);
e9aa4d8Claude441// Issue command center — global issue dashboard with AI-triage + autopilot signal
442app.route("/", issuesDashboardRoutes);
443// Personal activity timeline — every event across the user's repos, with
444// AI-driven events surfaced separately (the Gluecron differentiator).
445app.route("/", activityRoutes);
446// Unified inbox — mentions + review requests + CI failures + AI events in one timeline
447app.route("/", inboxRoutes);
56801e1Claude448// AI standup feed — daily / weekly Claude-generated team brief
449app.route("/", standupRoutes);
cc34156Claude450// Smart morning digest — AI-curated daily developer queue (/digest)
451app.route("/", digestRoutes);
79136bbClaude452
453// Auth routes (register, login, logout)
454app.route("/", authRoutes);
455
c63b860Claude456// BLOCK P1 — Password reset (forgot-password + reset-password)
457app.route("/", passwordResetRoutes);
458
459// BLOCK P2 — Email verification (verify-email + resend)
460app.route("/", emailVerificationRoutes);
461
cd4f63bTest User462// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
463app.route("/", magicLinkRoutes);
464
79136bbClaude465// Settings routes (profile, SSH keys)
466app.route("/", settingsRoutes);
467
ba9e143Claude468// Session management (SOC 2 CC6.1 — /settings/sessions)
469app.route("/", settingsSessionsRoutes);
470
7298a17Claude471// 2FA / TOTP settings (Block B4)
472app.route("/", settings2faRoutes);
473
e75eddcClaude474// Agent multiplayer — /settings/agents management UI
475app.route("/", settingsAgentsRoutes);
476
1d4ff60Claude477// Chat integrations — Slack / Discord / Teams (/settings/integrations
478// + /api/v2/integrations/{slack,discord}/*). See src/lib/chat-bot.ts.
479app.route("/", settingsIntegrationsRoutes);
480app.route("/", integrationsChatRoutes);
481
2df1f8cClaude482// WebAuthn / passkey routes (Block B5)
483app.route("/", passkeyRoutes);
484
058d752Claude485// OAuth 2.0 provider (Block B6)
486app.route("/", oauthRoutes);
487app.route("/", developerAppsRoutes);
369ad65ccanty labs488// OAuth / agent discovery metadata (RFC 8414 + RFC 9728) — lets claude.ai,
489// Cursor, Copilot, etc. auto-discover how to authenticate.
490app.route("/", wellKnownRoutes);
058d752Claude491
6fc53bdClaude492// Theme toggle (dark/light cookie)
493app.route("/", themeRoutes);
494
495// Audit log UI
496app.route("/", auditRoutes);
497
498// Reactions API (issues, PRs, comments)
499app.route("/", reactionRoutes);
500
24cf2caClaude501// Saved replies (per-user canned comment templates)
502app.route("/", savedReplyRoutes);
503
504// Environments + deployment history UI
505app.route("/", deploymentRoutes);
2c61840Claude506// Unified CI/CD pipeline timeline
507app.route("/", pipelineRoutes);
24cf2caClaude508
6563f0aClaude509// Organizations + teams (Block B1)
510app.route("/", orgRoutes);
511
c81ab7aClaude512// API tokens
513app.route("/", tokenRoutes);
514
59b6fb2Claude515// Notifications
3ef4c9dClaude516app.route("/", notificationRoutes);
517
79136bbClaude518// Repo settings (description, visibility, delete)
519app.route("/", repoSettings);
479dcd9Claude520// Per-repo automation settings (off / suggest / auto) — migration 0106
521app.route("/", automationSettingsRoutes);
79136bbClaude522
23d1a81Claude523// Repo collaborators (add/list/remove)
524app.route("/", collaboratorRoutes);
525
04f6b7fClaude526// Team-based repo collaborators (invite a whole team)
527app.route("/", teamCollaboratorRoutes);
528
529// Collaborator invite accept flow (token-based)
530app.route("/", invitesRoutes);
531
532// Real-time SSE endpoint (topic-based live updates)
533app.route("/", liveEventsRoutes);
534
3c03977Claude535// PR live co-editing — presence + cursors + content sync via SSE.
536app.route("/", prLiveRoutes);
537
c81ab7aClaude538// Webhooks management
539app.route("/", webhookRoutes);
540
79136bbClaude541// Compare view (branch diffs)
542app.route("/", compareRoutes);
543
544// Issue tracker
545app.route("/", issueRoutes);
546
85c4e13Claude547// Milestones — group issues + PRs toward a shared goal with due dates + progress tracking.
548// Mounted after issueRoutes so /:owner/:repo/issues/* paths win before the milestone patterns.
549app.route("/", milestonesRoutes);
550
f928118Claude551// Ship Agent — autonomous AI feature implementation
552app.route("/", shipAgentRoutes);
553
77cf834Claude554// AI Copilot Workspace — issue-to-PR autonomous agent
555app.route("/", workspaceRoutes);
2c61840Claude556app.route("/", workspaceHubRoutes);
77cf834Claude557
cb5a796Claude558// Comment moderation queue — owner-only `/:owner/:repo/comments/pending`
559// + per-row approve/reject/spam actions. Mounted before `pullRoutes` so
560// the `/:owner/:repo/comments/*` paths resolve before the broader PR
561// patterns kick in.
562app.route("/", commentModerationRoutes);
563
0074234Claude564// Pull requests
565app.route("/", pullRoutes);
09d5f39Claude566
2be65d0Claude567// Streaming PR review — SSE stream + embeddable widget
568// Mounted immediately after pullRoutes so /:owner/:repo/pulls/:number/review/*
569// resolves before the webRoutes catch-all takes over.
570import streamingReviewRoutes from "./routes/streaming-review";
571app.route("/", streamingReviewRoutes);
572
09d5f39Claude573// /stage PR preview — serve built static files from .stage-previews/{jobId}/
574// Registered immediately after pullRoutes so the path `/preview/:id/*` is
575// specific enough to never clash with repo browse routes (`/:owner/:repo/*`).
576app.get("/preview/:stageJobId/*", async (c) => {
577 const { stageJobId } = c.req.param();
578 // Validate job ID format (UUID)
579 if (!/^[0-9a-f-]{32,}$/i.test(stageJobId)) {
580 return c.text("Not found", 404);
581 }
582 const { getPreviewDir, isPreviewExpired } = await import("./lib/pr-stage");
583 if (isPreviewExpired(stageJobId)) {
584 return c.html(
585 "<html><body style='font-family:sans-serif;padding:40px;color:#888'>" +
586 "<h2>Preview expired</h2><p>This stage preview has expired (48h TTL). " +
587 "Comment <code>/stage</code> on the PR to redeploy.</p></body></html>",
588 410
589 );
590 }
591 const { join } = await import("path");
592 const previewDir = getPreviewDir(stageJobId);
593 // Extract the wildcard path after /preview/:id/
594 const rawPath = c.req.path.replace(/^\/preview\/[^/]+/, "") || "/";
595 const filePath = rawPath === "/" || rawPath === "" ? "/index.html" : rawPath;
596 const fullPath = join(previewDir, filePath);
597 const file = Bun.file(fullPath);
598 if (!(await file.exists())) {
599 // Try index.html fallback (SPA behaviour)
600 const indexFile = Bun.file(join(previewDir, "index.html"));
601 if (await indexFile.exists()) {
602 const html = await indexFile.text();
603 return c.html(html);
604 }
605 return c.text("Not found", 404);
606 }
607 const content = await file.arrayBuffer();
608 const ext = fullPath.split(".").pop()?.toLowerCase() ?? "";
609 const contentTypeMap: Record<string, string> = {
610 html: "text/html; charset=utf-8",
611 htm: "text/html; charset=utf-8",
612 css: "text/css; charset=utf-8",
613 js: "application/javascript; charset=utf-8",
614 mjs: "application/javascript; charset=utf-8",
615 json: "application/json; charset=utf-8",
616 png: "image/png",
617 jpg: "image/jpeg",
618 jpeg: "image/jpeg",
619 gif: "image/gif",
620 svg: "image/svg+xml",
621 ico: "image/x-icon",
622 webp: "image/webp",
623 woff: "font/woff",
624 woff2: "font/woff2",
625 ttf: "font/ttf",
626 txt: "text/plain; charset=utf-8",
627 xml: "application/xml",
628 webmanifest: "application/manifest+json",
629 };
630 const ct = contentTypeMap[ext] ?? "application/octet-stream";
631 return c.body(content, 200, {
632 "content-type": ct,
633 "cache-control": "public, max-age=300",
634 "x-stage-job-id": stageJobId,
635 });
636});
637
79ed944Claude638// PR sandboxes — runnable per-PR environments. Migration 0067.
639app.route("/", prSandboxRoutes);
0074234Claude640
9b3a183Claude641// Cloud dev environments — hosted VS Code in the browser. Migration 0072.
642app.route("/", devEnvRoutes);
643
c81ab7aClaude644// Fork
645app.route("/", forkRoutes);
646
0074234Claude647// Web file editor
648app.route("/", editorRoutes);
649
6f2809fClaude650// AI editor API routes (inline suggestions, explain, fix)
651app.route("/", aiEditorRoutes);
652
43de941Claude653// Contributors
654app.route("/", contributorRoutes);
655
699e5c7Claude656// Health liveness + metrics endpoints
2c34075Claude657app.route("/", healthRoutes);
658
f295f78Dictation App659// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
660app.route("/api/platform-status", platformStatus);
661
52ad8b1Claude662// Block L4 — Public stats counters (powers landing-page social proof)
663app.route("/", publicStatsRoutes);
664
665// Block L3 — Live /demo page + /api/v2/demo/* endpoints
666app.route("/", demoRoutes);
667
2316be6Claude668// Public /status — human-readable platform health page
669app.route("/", statusRoutes);
670
b1be050CC LABS App671// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
672// Mounted near the public status route so the two surfaces are visible
673// side-by-side; routes are gated by isSiteAdmin internally.
674app.route("/", adminStatusRoutes);
675
80bed05Claude676// /help — quickstart + API cheatsheet
677app.route("/", helpRoutes);
678
e0e4219Claude679// /docs — expanded documentation site (getting started, workflow YAML, MCP, API, agents)
680app.route("/", docsRoutes);
681
5f2e749Claude682// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
683// so the new editorial pricing layout wins the route; the legacy marketing
684// pricing remains as a safety net but is shadowed at the router.
685app.route("/", pricingRoutes);
686
e1fc7dbClaude687// /changelog — manually curated platform release history
688app.route("/", changelogRoutes);
689
9f29b65Claude690// Enterprise sales page + contact form lead capture.
691app.route("/", enterpriseRoutes);
692
b0148e9Claude693// /pricing, /features, /about — marketing surface
694app.route("/", marketingRoutes);
695
adf5e18Claude696// /developer-program — partner + marketplace revenue-share page
697app.route("/", developerProgramRoutes);
698
5618f9aClaude699// SEO: robots.txt + sitemap.xml
700app.route("/", seoRoutes);
701
05cdb85Claude702// /api/version — live build SHA + uptime; client poller uses this to
703// surface 'New version available — reload' banners on deploy.
704app.route("/", versionRoutes);
705
699e5c7Claude706// Health dashboard (per-repo health page)
707app.route("/", healthDashboardRoutes);
708
9dd96b9Test User709// Block R1 — site-admin operations console. MUST be mounted BEFORE
710// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
711// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
712app.route("/", adminOpsRoutes);
f2c00b4CC LABS App713// BLOCK W — Self-host status + bootstrap dashboard.
714app.route("/", adminSelfHostRoutes);
826eccfTest User715// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
716app.route("/", adminDiagnoseRoutes);
f9814d2Claude717// Unified admin command center — /admin/command
718app.route("/", adminCommandRoutes);
9dd96b9Test User719
16b325cClaude720// Insights (time-travel, dependencies, rollback)
721app.route("/", insightRoutes);
722
8286942Claude723// Engineering Intelligence Dashboard — /insights + /:owner/:repo/insights/engineering
724app.route("/", engineeringInsightsRoutes);
725
8d1483cClaude726// DORA metrics page (/:owner/:repo/insights/dora)
727app.route("/", doraRoutes);
728
f1ab587Claude729// Command center dashboard
730app.route("/", dashboardRoutes);
731
36b4cbdClaude732// Legal pages (terms, privacy, AUP)
733app.route("/", legalRoutes);
4b66018Claude734// Long-form legal sub-pages — /legal/{terms,privacy,acceptable-use,dmca}.
735// The main `legal.tsx` serves the short canonical paths (/terms, /privacy,
736// /acceptable-use); these are the formal versions that the legal pages
737// internally link to each other.
738app.route("/", legalTermsRoutes);
739app.route("/", legalPrivacyRoutes);
740app.route("/", legalAcceptableUseRoutes);
741app.route("/", legalDmcaRoutes);
36b4cbdClaude742
bdbd0deClaude743// GitHub import / migration
744app.route("/", importRoutes);
14c3cc8Claude745app.route("/", importBulkRoutes);
f390cfaCC LABS App746app.route("/", importSecretsRoutes);
bb2dea9Claude747// GitHub Actions → Gluecron gates.yml importer (stateless converter)
748app.route("/", actionsImporterRoutes);
14c3cc8Claude749app.route("/", migrationRoutes);
ba23fe2Claude750app.route("/", migrationAssistantRoutes);
9a8b8deClaude751// GitHub Org Migration Wizard — live progress bulk importer
752app.route("/", migrateRoutes);
14c3cc8Claude753
754// Spec-to-PR (experimental AI-generated draft PRs)
755app.route("/", specsRoutes);
23d0abfClaude756app.route("/", refactorRoutes);
b665cacClaude757app.route("/", codebaseMigratorRoutes);
bdbd0deClaude758
c81ab7aClaude759// Explore page
760app.route("/", exploreRoutes);
761
59b6fb2Claude762// Onboarding
763app.route("/", onboardingRoutes);
764
0316dbbClaude765// Admin + feature routes
766app.route("/", adminRoutes);
7293c67Claude767app.route("/", adminDeletionsRoutes);
768app.route("/", adminStripeRoutes);
ba9e143Claude769
770// SOC 2 security dashboard + readiness checklist (/admin/security, /admin/soc2)
771app.route("/", adminSecurityRoutes);
509c376Claude772app.route("/", adminIntegrationsRoutes);
bc519aeClaude773app.route("/", adminEnvHealthRoutes);
79ed944Claude774app.route("/", adminAdvancementRoutes);
f764c07Claude775app.route("/", adminDeploysRoutes);
776app.route("/", adminDeploysPageRoutes);
783dd46Claude777app.route("/", adminServerTargetsRoutes);
9aaa128Claude778app.route("/", deployTargetsRoutes);
90c7531Claude779app.route("/", claudeWebRoutes);
9dd96b9Test User780// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude781app.route("/", advisoriesRoutes);
782app.route("/", aiChangelogRoutes);
0a69faaClaude783// "Explain This Repo" — rich structured AI analysis dashboard (mounted before
784// the simpler aiExplainRoutes so the new routes win on /:owner/:repo/explain).
785app.route("/", explainRoutes);
0316dbbClaude786app.route("/", aiExplainRoutes);
2be65d0Claude787app.route("/", archaeologyRoutes);
0316dbbClaude788app.route("/", aiTestsRoutes);
789app.route("/", askRoutes);
38d31d3Claude790app.route("/", repoChatRoutes);
ee7e577Claude791// Personal cross-repo chat — `/chat` (user-scoped). Mounted alongside
792// repoChatRoutes so the two surfaces share the catch-all priority.
793app.route("/", personalChatRoutes);
0316dbbClaude794app.route("/", billingRoutes);
8809b87Claude795app.route("/", billingUsageRoutes);
6778ad2Claude796app.route("/", stripeWebhookRoutes);
0316dbbClaude797app.route("/", codeScanningRoutes);
da3fc18Claude798// Dependency CVE scanner findings page — /:owner/:repo/security/vulnerabilities
799app.route("/", securityRoutes);
0316dbbClaude800app.route("/", commitStatusesRoutes);
801app.route("/", copilotRoutes);
f5d020fClaude802app.route("/", pairProgrammerRoutes);
0316dbbClaude803app.route("/", depUpdaterRoutes);
804app.route("/", depsRoutes);
805app.route("/", discussionsRoutes);
806app.route("/", environmentsRoutes);
4bbacbeClaude807app.route("/", previewsRoutes);
79ed944Claude808app.route("/", docsTrackingRoutes);
0316dbbClaude809app.route("/", followsRoutes);
810app.route("/", gatesRoutes);
811app.route("/", gistsRoutes);
812app.route("/", graphqlRoutes);
2c2163eClaude813app.route("/", mcpRoutes);
0316dbbClaude814app.route("/", marketplaceRoutes);
5ca514aClaude815app.route("/", marketplaceAgentsRoutes);
0316dbbClaude816app.route("/", mergeQueueRoutes);
817app.route("/", mirrorsRoutes);
818app.route("/", orgInsightsRoutes);
b02ce30Claude819app.route("/", orgHealthRoutes);
0316dbbClaude820app.route("/", packagesRoutes);
821app.route("/", packagesApiRoutes);
845fd8aClaude822// OCI / Docker container registry — /v2/* (OCI Distribution Spec v1.0)
823app.route("/", ociRegistryRoutes);
0316dbbClaude824app.route("/", pagesRoutes);
825app.route("/", projectsRoutes);
826app.route("/", protectedTagsRoutes);
827app.route("/", pwaRoutes);
46d6165Claude828app.route("/", installRoutes);
cd4f63bTest User829// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
830app.route("/", dxtRoutes);
662ce86Claude831// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
832// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
833app.route("/", connectClaudeRoutes);
f5b9ef5Claude834// Claude Code Integration Receiver — /api/claude/connect + /api/claude/session.
835app.route("/", claudeIntegration);
836// Connect guide — public onboarding page (/connect/claude-guide).
837app.route("/", connectRoutes);
05ab9b1Claude838// Push Watch — per-commit live status (gates + deploy + latency) at /:owner/:repo/push/:sha
839app.route("/", pushWatchRoutes);
840// Org Secrets Manager — BLOCK M2 — /orgs/:slug/settings/secrets
841app.route("/", orgSecretsRoutes);
a2b3e99Claude842// Cross-repo code search — BLOCK M3 — /search/code + /api/search/code
843app.route("/", crossRepoSearchRoutes);
844// Browser push notifications — BLOCK M4 — /settings/notifications/push + /api/push/*
845app.route("/", pushNotifRoutes);
9fbe6cdClaude846// Developer Velocity Dashboard — BLOCK M9 — /:owner/:repo/insights/velocity
847app.route("/", velocityRoutes);
848// Stale Branch Cleanup — BLOCK M10 — /:owner/:repo/branches/stale
849app.route("/", staleBranchRoutes);
22f43f3Claude850// Repository Pulse — BLOCK M12 — /:owner/:repo/pulse
851app.route("/", pulseRoutes);
74d8c4dClaude852// Repository Health Score — BLOCK M14 — /:owner/:repo/insights/health
853app.route("/", healthScoreRoutes);
77cf834Claude854// Repository Health Score breakdown page — /:owner/:repo/health
855app.route("/", repoHealthRoutes);
74d8c4dClaude856// Hot Files Heatmap — BLOCK M16 — /:owner/:repo/insights/hotfiles
857app.route("/", hotFilesRoutes);
bcc4020Claude858// AI Technical Debt Map — /:owner/:repo/debt-map (visual debt graph + Claude analysis)
859app.route("/", debtMapRoutes);
1d6db4dClaude860// Bus Factor Analysis — /:owner/:repo/insights/bus-factor
861app.route("/", busFactorRoutes);
b02ce30Claude862// Test Gap Detector — /:owner/:repo/insights/test-gaps
863app.route("/", testGapsRoutes);
f5d020fClaude864// Cross-Repo Dependency Impact Detection — /:owner/:repo/pulls/:number/cross-repo-impact
865app.route("/", crossRepoImpactRoutes);
ebbb527Claude866// Hosted Claude tool-use loops — paste loop, get endpoint, billing meter.
867// See src/routes/claude-deploy.tsx + src/lib/hosted-claude-loop.ts.
868app.route("/", claudeDeployRoutes);
0316dbbClaude869app.route("/", releasesRoutes);
870app.route("/", requiredChecksRoutes);
871app.route("/", rulesetsRoutes);
872app.route("/", searchRoutes);
873app.route("/", semanticSearchRoutes);
77cf834Claude874app.route("/", nlSearchRoutes);
0316dbbClaude875app.route("/", signingKeysRoutes);
876app.route("/", sponsorsRoutes);
877app.route("/", ssoRoutes);
3a845e4Claude878// Enterprise per-org SAML 2.0 + OIDC SSO routes
879app.route("/", samlSsoRoutes);
880// SCIM 2.0 user provisioning endpoints
881app.route("/", scimRoutes);
882// Per-org SSO + SCIM admin settings UI
883app.route("/", orgSsoSettingsRoutes);
46d6165Claude884app.route("/", githubOauthRoutes);
582cdacClaude885app.route("/", googleOauthRoutes);
0316dbbClaude886app.route("/", symbolsRoutes);
887app.route("/", templatesRoutes);
888app.route("/", trafficRoutes);
889app.route("/", wikisRoutes);
890app.route("/", workflowsRoutes);
5ff9cc2Claude891app.route("/", workflowArtifactsRoutes);
892app.route("/", workflowSecretsRoutes);
46d6165Claude893app.route("/", sleepModeRoutes);
52ad8b1Claude894app.route("/", vsGithubRoutes);
0316dbbClaude895
45f3b73Claude896// Voice-to-PR — phone-first dictation → spec or issue
897app.route("/", voiceRoutes);
898
3122762Claude899// Blog / Devlog — public posts, no DB
900app.route("/", blogRoutes);
901
cd4f63bTest User902// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
903// before the web catch-all so the bare `/play` literal wins over the
904// `/:owner` user-profile route.
905app.route("/", playgroundRoutes);
906
891efbeClaude907// Shareable AI hours-saved OG image card + landing page.
908// /share/hours-saved?user=:username → 1200×630 SVG (og:image)
909// /share/:username → HTML page with og:image meta + Twitter share
910// Mounted BEFORE webRoutes so /share/* doesn't fall through to the /:owner profile route.
911app.route("/", shareRoutes);
912
79136bbClaude913// Web UI (catch-all, must be last)
914app.route("/", webRoutes);
915
c63b860Claude916// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
917// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude918app.notFound((c) => {
36cc17aClaude919 const user = c.get("user") ?? null;
79136bbClaude920 return c.html(
c63b860Claude921 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude922 404
923 );
924});
925
c63b860Claude926// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
927// view. Trace block only shown outside production.
79136bbClaude928app.onError((err, c) => {
80bed05Claude929 reportError(err, {
930 requestId: c.get("requestId"),
931 path: c.req.path,
932 method: c.req.method,
933 });
c63b860Claude934 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
935 // back to the context value set by request-context middleware.
936 const requestId =
937 c.req.header("x-request-id") ||
938 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude939 const user = c.get("user") ?? null;
c63b860Claude940 const trace =
941 process.env.NODE_ENV !== "production" && err && err.message
942 ? err.message
943 : undefined;
79136bbClaude944 return c.html(
c63b860Claude945 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude946 500
947 );
948});
949
950export default app;