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.tsxBlame499 lines · 4 contributors
79136bbClaude1import { Hono } from "hono";
2import { logger } from "hono/logger";
3import { cors } from "hono/cors";
05b973eClaude4import { compress } from "hono/compress";
c63b860Claude5// BLOCK O2 — shared error-page surface (404 / 500 / 403).
6import { NotFoundPage, ServerErrorPage } from "./views/error-page";
80bed05Claude7import { reportError } from "./lib/observability";
3ef4c9dClaude8import { requestContext } from "./middleware/request-context";
9import { rateLimit } from "./middleware/rate-limit";
79136bbClaude10import gitRoutes from "./routes/git";
11import apiRoutes from "./routes/api";
45e31d0Claude12import apiV2Routes from "./routes/api-v2";
13import apiDocsRoutes from "./routes/api-docs";
79136bbClaude14import authRoutes from "./routes/auth";
c63b860Claude15import passwordResetRoutes from "./routes/password-reset";
16import emailVerificationRoutes from "./routes/email-verification";
cd4f63bTest User17import magicLinkRoutes from "./routes/magic-link";
79136bbClaude18import settingsRoutes from "./routes/settings";
7298a17Claude19import settings2faRoutes from "./routes/settings-2fa";
79136bbClaude20import issueRoutes from "./routes/issues";
21import repoSettings from "./routes/repo-settings";
23d1a81Claude22import collaboratorRoutes from "./routes/collaborators";
04f6b7fClaude23import teamCollaboratorRoutes from "./routes/team-collaborators";
24import invitesRoutes from "./routes/invites";
25import liveEventsRoutes from "./routes/live-events";
79136bbClaude26import compareRoutes from "./routes/compare";
0074234Claude27import pullRoutes from "./routes/pulls";
28import editorRoutes from "./routes/editor";
c81ab7aClaude29import forkRoutes from "./routes/fork";
30import webhookRoutes from "./routes/webhooks";
31import exploreRoutes from "./routes/explore";
32import tokenRoutes from "./routes/tokens";
43de941Claude33import contributorRoutes from "./routes/contributors";
699e5c7Claude34import healthRoutes from "./routes/health-probe";
35import healthDashboardRoutes from "./routes/health";
2316be6Claude36import statusRoutes from "./routes/status";
b1be050CC LABS App37import adminStatusRoutes from "./routes/admin-status";
80bed05Claude38import helpRoutes from "./routes/help";
b0148e9Claude39import marketingRoutes from "./routes/marketing";
5f2e749Claude40import pricingRoutes from "./routes/pricing";
5618f9aClaude41import seoRoutes from "./routes/seo";
05cdb85Claude42import versionRoutes from "./routes/version";
f295f78Dictation App43import { platformStatus } from "./routes/platform-status";
52ad8b1Claude44import publicStatsRoutes from "./routes/public-stats";
45import demoRoutes from "./routes/demo";
16b325cClaude46import insightRoutes from "./routes/insights";
f1ab587Claude47import dashboardRoutes from "./routes/dashboard";
36b4cbdClaude48import legalRoutes from "./routes/legal";
bdbd0deClaude49import importRoutes from "./routes/import";
14c3cc8Claude50import importBulkRoutes from "./routes/import-bulk";
f390cfaCC LABS App51import importSecretsRoutes from "./routes/import-secrets";
14c3cc8Claude52import migrationRoutes from "./routes/migrations";
53import specsRoutes from "./routes/specs";
79136bbClaude54import webRoutes from "./routes/web";
0316dbbClaude55import hookRoutes from "./routes/hooks";
56import eventsRoutes from "./routes/events";
57import passkeyRoutes from "./routes/passkeys";
58import oauthRoutes from "./routes/oauth";
59import developerAppsRoutes from "./routes/developer-apps";
60import themeRoutes from "./routes/theme";
61import auditRoutes from "./routes/audit";
62import reactionRoutes from "./routes/reactions";
63import savedReplyRoutes from "./routes/saved-replies";
64import deploymentRoutes from "./routes/deployments";
65import orgRoutes from "./routes/orgs";
66import notificationRoutes from "./routes/notifications";
67import onboardingRoutes from "./routes/onboarding";
68import adminRoutes from "./routes/admin";
f764c07Claude69import adminDeploysRoutes from "./routes/admin-deploys";
70import adminDeploysPageRoutes from "./routes/admin-deploys-page";
9dd96b9Test User71import adminOpsRoutes from "./routes/admin-ops";
f2c00b4CC LABS App72import adminSelfHostRoutes from "./routes/admin-self-host";
826eccfTest User73import adminDiagnoseRoutes from "./routes/admin-diagnose";
0316dbbClaude74import advisoriesRoutes from "./routes/advisories";
75import aiChangelogRoutes from "./routes/ai-changelog";
76import aiExplainRoutes from "./routes/ai-explain";
77import aiTestsRoutes from "./routes/ai-tests";
78import askRoutes from "./routes/ask";
79import billingRoutes from "./routes/billing";
6778ad2Claude80import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude81import codeScanningRoutes from "./routes/code-scanning";
82import commitStatusesRoutes from "./routes/commit-statuses";
83import copilotRoutes from "./routes/copilot";
84import depUpdaterRoutes from "./routes/dep-updater";
85import depsRoutes from "./routes/deps";
86import discussionsRoutes from "./routes/discussions";
87import environmentsRoutes from "./routes/environments";
88import followsRoutes from "./routes/follows";
89import gatesRoutes from "./routes/gates";
90import gistsRoutes from "./routes/gists";
91import graphqlRoutes from "./routes/graphql";
2c2163eClaude92import mcpRoutes from "./routes/mcp";
0316dbbClaude93import marketplaceRoutes from "./routes/marketplace";
94import mergeQueueRoutes from "./routes/merge-queue";
95import mirrorsRoutes from "./routes/mirrors";
96import orgInsightsRoutes from "./routes/org-insights";
97import packagesRoutes from "./routes/packages";
98import packagesApiRoutes from "./routes/packages-api";
99import pagesRoutes from "./routes/pages";
100import projectsRoutes from "./routes/projects";
101import protectedTagsRoutes from "./routes/protected-tags";
102import pwaRoutes from "./routes/pwa";
46d6165Claude103import installRoutes from "./routes/install";
cd4f63bTest User104import dxtRoutes from "./routes/dxt";
662ce86Claude105import connectClaudeRoutes from "./routes/connect-claude";
0316dbbClaude106import releasesRoutes from "./routes/releases";
107import requiredChecksRoutes from "./routes/required-checks";
108import rulesetsRoutes from "./routes/rulesets";
109import searchRoutes from "./routes/search";
110import semanticSearchRoutes from "./routes/semantic-search";
111import signingKeysRoutes from "./routes/signing-keys";
112import sponsorsRoutes from "./routes/sponsors";
113import ssoRoutes from "./routes/sso";
46d6165Claude114import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude115import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude116import symbolsRoutes from "./routes/symbols";
117import templatesRoutes from "./routes/templates";
118import trafficRoutes from "./routes/traffic";
119import wikisRoutes from "./routes/wikis";
120import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude121import workflowArtifactsRoutes from "./routes/workflow-artifacts";
122import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude123import sleepModeRoutes from "./routes/sleep-mode";
52ad8b1Claude124import vsGithubRoutes from "./routes/vs-github";
cd4f63bTest User125import playgroundRoutes from "./routes/playground";
59b6fb2Claude126import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
127import { csrfToken, csrfProtect } from "./middleware/csrf";
79136bbClaude128
2316901Claude129import type { AuthEnv } from "./middleware/auth";
bf19c50Test User130import { softAuth } from "./middleware/auth";
2316901Claude131
132const app = new Hono<AuthEnv>();
79136bbClaude133
3ef4c9dClaude134// Request context (request ID, start time) runs before everything else
135app.use("*", requestContext);
05b973eClaude136// Middleware — compression first (wraps all responses)
137app.use("*", compress());
138// Logger only on non-git routes to avoid overhead on clone/push
139app.use("*", async (c, next) => {
140 if (c.req.path.includes(".git/")) return next();
141 return logger()(c, next);
142});
79136bbClaude143app.use("/api/*", cors());
bf19c50Test User144// Global softAuth — populates c.get("user") for every downstream middleware
145// + route. This was previously per-route, which meant rate-limit middleware
146// (and anything else inspecting auth state) always saw a null user. Keep
147// individual routes free to add requireAuth on top for hard gating; this
148// just establishes the user object cheaply.
149app.use("*", softAuth);
290ea77Claude150
36cc17aClaude151// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude152// pre-redesign markup. JSON / static assets keep their own cache rules; only
153// text/html responses get the no-cache stamp. Without this, every push to
154// main left users staring at cached 80s-looking pages from before the design
155// landed.
36cc17aClaude156//
157// We deliberately use `private, no-cache, must-revalidate` rather than
158// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
159// which makes every Back/Forward press a cold server round-trip — that
160// contributed to the "every nav feels like a fresh login" UX complaint.
161// `no-cache` still revalidates on direct fetch but lets bfcache hold the
162// page in memory between navigations.
290ea77Claude163app.use("*", async (c, next) => {
164 await next();
165 const ct = c.res.headers.get("content-type") || "";
166 if (ct.startsWith("text/html")) {
36cc17aClaude167 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude168 }
169});
826eccfTest User170// Rate-limit API + auth endpoints.
171//
a41e675Test User172// `/api/*`: 1000/min per IP — generous so an admin clicking around the
173// operator console (or a CDN/proxy concentrating multiple users behind one
174// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
175// rate limits below, not this one.
176//
177// `authedMultiplier` is set but only fires when an upstream middleware has
178// already populated c.get("user") — most app.use() chains apply softAuth
179// per-route, so the multiplier is best-effort. Keep the anonymous base
180// high enough that humans never feel it.
181//
182// Skip-paths: dashboard plumbing endpoints that the layout polls on a
183// fixed cadence and that we don't want consuming any bucket:
184// /api/version — layout polls every 15s
826eccfTest User185// /api/notifications/count — nav bell unread-count fetcher
186// /pwa/vapid-public-key — fetched once per push-notification opt-in
187app.use(
188 "/api/*",
a41e675Test User189 rateLimit(1000, 60_000, "api", {
826eccfTest User190 authedMultiplier: 4,
191 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
192 })
193);
0316dbbClaude194app.use("/login", rateLimit(20, 60_000, "login"));
195app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude196// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
197app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User198// BLOCK Q2 — throttle magic-link sign-in for the same reason.
199app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude200
59b6fb2Claude201// CSRF protection — set token on all requests, validate on mutations
202app.use("*", csrfToken);
203app.use("*", csrfProtect);
204
45e31d0Claude205// Rate limit auth routes
206app.use("/login", authRateLimit);
207app.use("/register", authRateLimit);
208
59b6fb2Claude209// Rate limit git operations
210app.use("/:owner/:repo.git/*", gitRateLimit);
211
212// Rate limit search
213app.use("/:owner/:repo/search", searchRateLimit);
214app.use("/explore", searchRateLimit);
79136bbClaude215
216// Git Smart HTTP protocol routes (must be before web routes)
217app.route("/", gitRoutes);
218
45e31d0Claude219// REST API v1 (legacy)
79136bbClaude220app.route("/", apiRoutes);
221
52ad8b1Claude222// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
223// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
224// router's catch-shape, and BEFORE adminRoutes so the live /demo page
225// wins over the legacy /demo redirect in src/routes/admin.tsx.
226app.route("/", demoRoutes);
227
0316dbbClaude228// REST API v2 (basePath /api/v2)
229app.route("/", apiV2Routes);
230
ad6d4adClaude231// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
232app.route("/", hookRoutes);
21f8dbdClaude233app.route("/api/events", eventsRoutes);
ad6d4adClaude234
45e31d0Claude235// API documentation
236app.route("/", apiDocsRoutes);
79136bbClaude237
238// Auth routes (register, login, logout)
239app.route("/", authRoutes);
240
c63b860Claude241// BLOCK P1 — Password reset (forgot-password + reset-password)
242app.route("/", passwordResetRoutes);
243
244// BLOCK P2 — Email verification (verify-email + resend)
245app.route("/", emailVerificationRoutes);
246
cd4f63bTest User247// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
248app.route("/", magicLinkRoutes);
249
79136bbClaude250// Settings routes (profile, SSH keys)
251app.route("/", settingsRoutes);
252
7298a17Claude253// 2FA / TOTP settings (Block B4)
254app.route("/", settings2faRoutes);
255
2df1f8cClaude256// WebAuthn / passkey routes (Block B5)
257app.route("/", passkeyRoutes);
258
058d752Claude259// OAuth 2.0 provider (Block B6)
260app.route("/", oauthRoutes);
261app.route("/", developerAppsRoutes);
262
6fc53bdClaude263// Theme toggle (dark/light cookie)
264app.route("/", themeRoutes);
265
266// Audit log UI
267app.route("/", auditRoutes);
268
269// Reactions API (issues, PRs, comments)
270app.route("/", reactionRoutes);
271
24cf2caClaude272// Saved replies (per-user canned comment templates)
273app.route("/", savedReplyRoutes);
274
275// Environments + deployment history UI
276app.route("/", deploymentRoutes);
277
6563f0aClaude278// Organizations + teams (Block B1)
279app.route("/", orgRoutes);
280
c81ab7aClaude281// API tokens
282app.route("/", tokenRoutes);
283
59b6fb2Claude284// Notifications
3ef4c9dClaude285app.route("/", notificationRoutes);
286
79136bbClaude287// Repo settings (description, visibility, delete)
288app.route("/", repoSettings);
289
23d1a81Claude290// Repo collaborators (add/list/remove)
291app.route("/", collaboratorRoutes);
292
04f6b7fClaude293// Team-based repo collaborators (invite a whole team)
294app.route("/", teamCollaboratorRoutes);
295
296// Collaborator invite accept flow (token-based)
297app.route("/", invitesRoutes);
298
299// Real-time SSE endpoint (topic-based live updates)
300app.route("/", liveEventsRoutes);
301
c81ab7aClaude302// Webhooks management
303app.route("/", webhookRoutes);
304
79136bbClaude305// Compare view (branch diffs)
306app.route("/", compareRoutes);
307
308// Issue tracker
309app.route("/", issueRoutes);
310
0074234Claude311// Pull requests
312app.route("/", pullRoutes);
313
c81ab7aClaude314// Fork
315app.route("/", forkRoutes);
316
0074234Claude317// Web file editor
318app.route("/", editorRoutes);
319
43de941Claude320// Contributors
321app.route("/", contributorRoutes);
322
699e5c7Claude323// Health liveness + metrics endpoints
2c34075Claude324app.route("/", healthRoutes);
325
f295f78Dictation App326// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
327app.route("/api/platform-status", platformStatus);
328
52ad8b1Claude329// Block L4 — Public stats counters (powers landing-page social proof)
330app.route("/", publicStatsRoutes);
331
332// Block L3 — Live /demo page + /api/v2/demo/* endpoints
333app.route("/", demoRoutes);
334
2316be6Claude335// Public /status — human-readable platform health page
336app.route("/", statusRoutes);
337
b1be050CC LABS App338// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
339// Mounted near the public status route so the two surfaces are visible
340// side-by-side; routes are gated by isSiteAdmin internally.
341app.route("/", adminStatusRoutes);
342
80bed05Claude343// /help — quickstart + API cheatsheet
344app.route("/", helpRoutes);
345
5f2e749Claude346// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
347// so the new editorial pricing layout wins the route; the legacy marketing
348// pricing remains as a safety net but is shadowed at the router.
349app.route("/", pricingRoutes);
350
b0148e9Claude351// /pricing, /features, /about — marketing surface
352app.route("/", marketingRoutes);
353
5618f9aClaude354// SEO: robots.txt + sitemap.xml
355app.route("/", seoRoutes);
356
05cdb85Claude357// /api/version — live build SHA + uptime; client poller uses this to
358// surface 'New version available — reload' banners on deploy.
359app.route("/", versionRoutes);
360
699e5c7Claude361// Health dashboard (per-repo health page)
362app.route("/", healthDashboardRoutes);
363
9dd96b9Test User364// Block R1 — site-admin operations console. MUST be mounted BEFORE
365// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
366// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
367app.route("/", adminOpsRoutes);
f2c00b4CC LABS App368// BLOCK W — Self-host status + bootstrap dashboard.
369app.route("/", adminSelfHostRoutes);
826eccfTest User370// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
371app.route("/", adminDiagnoseRoutes);
9dd96b9Test User372
16b325cClaude373// Insights (time-travel, dependencies, rollback)
374app.route("/", insightRoutes);
375
f1ab587Claude376// Command center dashboard
377app.route("/", dashboardRoutes);
378
36b4cbdClaude379// Legal pages (terms, privacy, AUP)
380app.route("/", legalRoutes);
381
bdbd0deClaude382// GitHub import / migration
383app.route("/", importRoutes);
14c3cc8Claude384app.route("/", importBulkRoutes);
f390cfaCC LABS App385app.route("/", importSecretsRoutes);
14c3cc8Claude386app.route("/", migrationRoutes);
387
388// Spec-to-PR (experimental AI-generated draft PRs)
389app.route("/", specsRoutes);
bdbd0deClaude390
c81ab7aClaude391// Explore page
392app.route("/", exploreRoutes);
393
59b6fb2Claude394// Onboarding
395app.route("/", onboardingRoutes);
396
0316dbbClaude397// Admin + feature routes
398app.route("/", adminRoutes);
f764c07Claude399app.route("/", adminDeploysRoutes);
400app.route("/", adminDeploysPageRoutes);
9dd96b9Test User401// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude402app.route("/", advisoriesRoutes);
403app.route("/", aiChangelogRoutes);
404app.route("/", aiExplainRoutes);
405app.route("/", aiTestsRoutes);
406app.route("/", askRoutes);
407app.route("/", billingRoutes);
6778ad2Claude408app.route("/", stripeWebhookRoutes);
0316dbbClaude409app.route("/", codeScanningRoutes);
410app.route("/", commitStatusesRoutes);
411app.route("/", copilotRoutes);
412app.route("/", depUpdaterRoutes);
413app.route("/", depsRoutes);
414app.route("/", discussionsRoutes);
415app.route("/", environmentsRoutes);
416app.route("/", followsRoutes);
417app.route("/", gatesRoutes);
418app.route("/", gistsRoutes);
419app.route("/", graphqlRoutes);
2c2163eClaude420app.route("/", mcpRoutes);
0316dbbClaude421app.route("/", marketplaceRoutes);
422app.route("/", mergeQueueRoutes);
423app.route("/", mirrorsRoutes);
424app.route("/", orgInsightsRoutes);
425app.route("/", packagesRoutes);
426app.route("/", packagesApiRoutes);
427app.route("/", pagesRoutes);
428app.route("/", projectsRoutes);
429app.route("/", protectedTagsRoutes);
430app.route("/", pwaRoutes);
46d6165Claude431app.route("/", installRoutes);
cd4f63bTest User432// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
433app.route("/", dxtRoutes);
662ce86Claude434// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
435// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
436app.route("/", connectClaudeRoutes);
0316dbbClaude437app.route("/", releasesRoutes);
438app.route("/", requiredChecksRoutes);
439app.route("/", rulesetsRoutes);
440app.route("/", searchRoutes);
441app.route("/", semanticSearchRoutes);
442app.route("/", signingKeysRoutes);
443app.route("/", sponsorsRoutes);
444app.route("/", ssoRoutes);
46d6165Claude445app.route("/", githubOauthRoutes);
582cdacClaude446app.route("/", googleOauthRoutes);
0316dbbClaude447app.route("/", symbolsRoutes);
448app.route("/", templatesRoutes);
449app.route("/", trafficRoutes);
450app.route("/", wikisRoutes);
451app.route("/", workflowsRoutes);
5ff9cc2Claude452app.route("/", workflowArtifactsRoutes);
453app.route("/", workflowSecretsRoutes);
46d6165Claude454app.route("/", sleepModeRoutes);
52ad8b1Claude455app.route("/", vsGithubRoutes);
0316dbbClaude456
cd4f63bTest User457// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
458// before the web catch-all so the bare `/play` literal wins over the
459// `/:owner` user-profile route.
460app.route("/", playgroundRoutes);
461
79136bbClaude462// Web UI (catch-all, must be last)
463app.route("/", webRoutes);
464
c63b860Claude465// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
466// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude467app.notFound((c) => {
36cc17aClaude468 const user = c.get("user") ?? null;
79136bbClaude469 return c.html(
c63b860Claude470 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude471 404
472 );
473});
474
c63b860Claude475// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
476// view. Trace block only shown outside production.
79136bbClaude477app.onError((err, c) => {
80bed05Claude478 reportError(err, {
479 requestId: c.get("requestId"),
480 path: c.req.path,
481 method: c.req.method,
482 });
c63b860Claude483 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
484 // back to the context value set by request-context middleware.
485 const requestId =
486 c.req.header("x-request-id") ||
487 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude488 const user = c.get("user") ?? null;
c63b860Claude489 const trace =
490 process.env.NODE_ENV !== "production" && err && err.message
491 ? err.message
492 : undefined;
79136bbClaude493 return c.html(
c63b860Claude494 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude495 500
496 );
497});
498
499export default app;