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.tsxBlame501 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";
509c376Claude74import adminIntegrationsRoutes from "./routes/admin-integrations";
0316dbbClaude75import advisoriesRoutes from "./routes/advisories";
76import aiChangelogRoutes from "./routes/ai-changelog";
77import aiExplainRoutes from "./routes/ai-explain";
78import aiTestsRoutes from "./routes/ai-tests";
79import askRoutes from "./routes/ask";
80import billingRoutes from "./routes/billing";
6778ad2Claude81import stripeWebhookRoutes from "./routes/stripe-webhook";
0316dbbClaude82import codeScanningRoutes from "./routes/code-scanning";
83import commitStatusesRoutes from "./routes/commit-statuses";
84import copilotRoutes from "./routes/copilot";
85import depUpdaterRoutes from "./routes/dep-updater";
86import depsRoutes from "./routes/deps";
87import discussionsRoutes from "./routes/discussions";
88import environmentsRoutes from "./routes/environments";
89import followsRoutes from "./routes/follows";
90import gatesRoutes from "./routes/gates";
91import gistsRoutes from "./routes/gists";
92import graphqlRoutes from "./routes/graphql";
2c2163eClaude93import mcpRoutes from "./routes/mcp";
0316dbbClaude94import marketplaceRoutes from "./routes/marketplace";
95import mergeQueueRoutes from "./routes/merge-queue";
96import mirrorsRoutes from "./routes/mirrors";
97import orgInsightsRoutes from "./routes/org-insights";
98import packagesRoutes from "./routes/packages";
99import packagesApiRoutes from "./routes/packages-api";
100import pagesRoutes from "./routes/pages";
101import projectsRoutes from "./routes/projects";
102import protectedTagsRoutes from "./routes/protected-tags";
103import pwaRoutes from "./routes/pwa";
46d6165Claude104import installRoutes from "./routes/install";
cd4f63bTest User105import dxtRoutes from "./routes/dxt";
662ce86Claude106import connectClaudeRoutes from "./routes/connect-claude";
0316dbbClaude107import releasesRoutes from "./routes/releases";
108import requiredChecksRoutes from "./routes/required-checks";
109import rulesetsRoutes from "./routes/rulesets";
110import searchRoutes from "./routes/search";
111import semanticSearchRoutes from "./routes/semantic-search";
112import signingKeysRoutes from "./routes/signing-keys";
113import sponsorsRoutes from "./routes/sponsors";
114import ssoRoutes from "./routes/sso";
46d6165Claude115import githubOauthRoutes from "./routes/github-oauth";
582cdacClaude116import googleOauthRoutes from "./routes/google-oauth";
0316dbbClaude117import symbolsRoutes from "./routes/symbols";
118import templatesRoutes from "./routes/templates";
119import trafficRoutes from "./routes/traffic";
120import wikisRoutes from "./routes/wikis";
121import workflowsRoutes from "./routes/workflows";
5ff9cc2Claude122import workflowArtifactsRoutes from "./routes/workflow-artifacts";
123import workflowSecretsRoutes from "./routes/workflow-secrets";
46d6165Claude124import sleepModeRoutes from "./routes/sleep-mode";
52ad8b1Claude125import vsGithubRoutes from "./routes/vs-github";
cd4f63bTest User126import playgroundRoutes from "./routes/playground";
59b6fb2Claude127import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
128import { csrfToken, csrfProtect } from "./middleware/csrf";
79136bbClaude129
2316901Claude130import type { AuthEnv } from "./middleware/auth";
bf19c50Test User131import { softAuth } from "./middleware/auth";
2316901Claude132
133const app = new Hono<AuthEnv>();
79136bbClaude134
3ef4c9dClaude135// Request context (request ID, start time) runs before everything else
136app.use("*", requestContext);
05b973eClaude137// Middleware — compression first (wraps all responses)
138app.use("*", compress());
139// Logger only on non-git routes to avoid overhead on clone/push
140app.use("*", async (c, next) => {
141 if (c.req.path.includes(".git/")) return next();
142 return logger()(c, next);
143});
79136bbClaude144app.use("/api/*", cors());
bf19c50Test User145// Global softAuth — populates c.get("user") for every downstream middleware
146// + route. This was previously per-route, which meant rate-limit middleware
147// (and anything else inspecting auth state) always saw a null user. Keep
148// individual routes free to add requireAuth on top for hard gating; this
149// just establishes the user object cheaply.
150app.use("*", softAuth);
290ea77Claude151
36cc17aClaude152// Force-revalidate HTML on every request — kills browser cache holding stale
290ea77Claude153// pre-redesign markup. JSON / static assets keep their own cache rules; only
154// text/html responses get the no-cache stamp. Without this, every push to
155// main left users staring at cached 80s-looking pages from before the design
156// landed.
36cc17aClaude157//
158// We deliberately use `private, no-cache, must-revalidate` rather than
159// `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache),
160// which makes every Back/Forward press a cold server round-trip — that
161// contributed to the "every nav feels like a fresh login" UX complaint.
162// `no-cache` still revalidates on direct fetch but lets bfcache hold the
163// page in memory between navigations.
290ea77Claude164app.use("*", async (c, next) => {
165 await next();
166 const ct = c.res.headers.get("content-type") || "";
167 if (ct.startsWith("text/html")) {
36cc17aClaude168 c.header("cache-control", "private, no-cache, must-revalidate");
290ea77Claude169 }
170});
826eccfTest User171// Rate-limit API + auth endpoints.
172//
a41e675Test User173// `/api/*`: 1000/min per IP — generous so an admin clicking around the
174// operator console (or a CDN/proxy concentrating multiple users behind one
175// IP) doesn't hit the wall. Bot-resistant headroom comes from the auth
176// rate limits below, not this one.
177//
178// `authedMultiplier` is set but only fires when an upstream middleware has
179// already populated c.get("user") — most app.use() chains apply softAuth
180// per-route, so the multiplier is best-effort. Keep the anonymous base
181// high enough that humans never feel it.
182//
183// Skip-paths: dashboard plumbing endpoints that the layout polls on a
184// fixed cadence and that we don't want consuming any bucket:
185// /api/version — layout polls every 15s
826eccfTest User186// /api/notifications/count — nav bell unread-count fetcher
187// /pwa/vapid-public-key — fetched once per push-notification opt-in
188app.use(
189 "/api/*",
a41e675Test User190 rateLimit(1000, 60_000, "api", {
826eccfTest User191 authedMultiplier: 4,
192 skipPaths: ["/api/version", "/api/notifications/count", "/pwa/vapid-public-key"],
193 })
194);
0316dbbClaude195app.use("/login", rateLimit(20, 60_000, "login"));
196app.use("/register", rateLimit(10, 60_000, "register"));
c63b860Claude197// BLOCK P1 — throttle forgot-password to deter enumeration + mail spam.
198app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password"));
cd4f63bTest User199// BLOCK Q2 — throttle magic-link sign-in for the same reason.
200app.use("/login/magic", rateLimit(5, 60_000, "magic-link"));
79136bbClaude201
59b6fb2Claude202// CSRF protection — set token on all requests, validate on mutations
203app.use("*", csrfToken);
204app.use("*", csrfProtect);
205
45e31d0Claude206// Rate limit auth routes
207app.use("/login", authRateLimit);
208app.use("/register", authRateLimit);
209
59b6fb2Claude210// Rate limit git operations
211app.use("/:owner/:repo.git/*", gitRateLimit);
212
213// Rate limit search
214app.use("/:owner/:repo/search", searchRateLimit);
215app.use("/explore", searchRateLimit);
79136bbClaude216
217// Git Smart HTTP protocol routes (must be before web routes)
218app.route("/", gitRoutes);
219
45e31d0Claude220// REST API v1 (legacy)
79136bbClaude221app.route("/", apiRoutes);
222
52ad8b1Claude223// Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE
224// apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base
225// router's catch-shape, and BEFORE adminRoutes so the live /demo page
226// wins over the legacy /demo redirect in src/routes/admin.tsx.
227app.route("/", demoRoutes);
228
0316dbbClaude229// REST API v2 (basePath /api/v2)
230app.route("/", apiV2Routes);
231
ad6d4adClaude232// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
233app.route("/", hookRoutes);
21f8dbdClaude234app.route("/api/events", eventsRoutes);
ad6d4adClaude235
45e31d0Claude236// API documentation
237app.route("/", apiDocsRoutes);
79136bbClaude238
239// Auth routes (register, login, logout)
240app.route("/", authRoutes);
241
c63b860Claude242// BLOCK P1 — Password reset (forgot-password + reset-password)
243app.route("/", passwordResetRoutes);
244
245// BLOCK P2 — Email verification (verify-email + resend)
246app.route("/", emailVerificationRoutes);
247
cd4f63bTest User248// BLOCK Q2 — Magic-link sign-in (/login/magic + callback)
249app.route("/", magicLinkRoutes);
250
79136bbClaude251// Settings routes (profile, SSH keys)
252app.route("/", settingsRoutes);
253
7298a17Claude254// 2FA / TOTP settings (Block B4)
255app.route("/", settings2faRoutes);
256
2df1f8cClaude257// WebAuthn / passkey routes (Block B5)
258app.route("/", passkeyRoutes);
259
058d752Claude260// OAuth 2.0 provider (Block B6)
261app.route("/", oauthRoutes);
262app.route("/", developerAppsRoutes);
263
6fc53bdClaude264// Theme toggle (dark/light cookie)
265app.route("/", themeRoutes);
266
267// Audit log UI
268app.route("/", auditRoutes);
269
270// Reactions API (issues, PRs, comments)
271app.route("/", reactionRoutes);
272
24cf2caClaude273// Saved replies (per-user canned comment templates)
274app.route("/", savedReplyRoutes);
275
276// Environments + deployment history UI
277app.route("/", deploymentRoutes);
278
6563f0aClaude279// Organizations + teams (Block B1)
280app.route("/", orgRoutes);
281
c81ab7aClaude282// API tokens
283app.route("/", tokenRoutes);
284
59b6fb2Claude285// Notifications
3ef4c9dClaude286app.route("/", notificationRoutes);
287
79136bbClaude288// Repo settings (description, visibility, delete)
289app.route("/", repoSettings);
290
23d1a81Claude291// Repo collaborators (add/list/remove)
292app.route("/", collaboratorRoutes);
293
04f6b7fClaude294// Team-based repo collaborators (invite a whole team)
295app.route("/", teamCollaboratorRoutes);
296
297// Collaborator invite accept flow (token-based)
298app.route("/", invitesRoutes);
299
300// Real-time SSE endpoint (topic-based live updates)
301app.route("/", liveEventsRoutes);
302
c81ab7aClaude303// Webhooks management
304app.route("/", webhookRoutes);
305
79136bbClaude306// Compare view (branch diffs)
307app.route("/", compareRoutes);
308
309// Issue tracker
310app.route("/", issueRoutes);
311
0074234Claude312// Pull requests
313app.route("/", pullRoutes);
314
c81ab7aClaude315// Fork
316app.route("/", forkRoutes);
317
0074234Claude318// Web file editor
319app.route("/", editorRoutes);
320
43de941Claude321// Contributors
322app.route("/", contributorRoutes);
323
699e5c7Claude324// Health liveness + metrics endpoints
2c34075Claude325app.route("/", healthRoutes);
326
f295f78Dictation App327// Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md)
328app.route("/api/platform-status", platformStatus);
329
52ad8b1Claude330// Block L4 — Public stats counters (powers landing-page social proof)
331app.route("/", publicStatsRoutes);
332
333// Block L3 — Live /demo page + /api/v2/demo/* endpoints
334app.route("/", demoRoutes);
335
2316be6Claude336// Public /status — human-readable platform health page
337app.route("/", statusRoutes);
338
b1be050CC LABS App339// BLOCK S4 — Site-admin synthetic-monitor dashboard (/admin/status).
340// Mounted near the public status route so the two surfaces are visible
341// side-by-side; routes are gated by isSiteAdmin internally.
342app.route("/", adminStatusRoutes);
343
80bed05Claude344// /help — quickstart + API cheatsheet
345app.route("/", helpRoutes);
346
5f2e749Claude347// L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing
348// so the new editorial pricing layout wins the route; the legacy marketing
349// pricing remains as a safety net but is shadowed at the router.
350app.route("/", pricingRoutes);
351
b0148e9Claude352// /pricing, /features, /about — marketing surface
353app.route("/", marketingRoutes);
354
5618f9aClaude355// SEO: robots.txt + sitemap.xml
356app.route("/", seoRoutes);
357
05cdb85Claude358// /api/version — live build SHA + uptime; client poller uses this to
359// surface 'New version available — reload' banners on deploy.
360app.route("/", versionRoutes);
361
699e5c7Claude362// Health dashboard (per-repo health page)
363app.route("/", healthDashboardRoutes);
364
9dd96b9Test User365// Block R1 — site-admin operations console. MUST be mounted BEFORE
366// insightRoutes because its POST `/:owner/:repo/rollback` catch-all would
367// otherwise intercept `/admin/ops/rollback` (matching :owner=admin :repo=ops).
368app.route("/", adminOpsRoutes);
f2c00b4CC LABS App369// BLOCK W — Self-host status + bootstrap dashboard.
370app.route("/", adminSelfHostRoutes);
826eccfTest User371// BLOCK X — AI health-scan diagnose page (/admin/diagnose).
372app.route("/", adminDiagnoseRoutes);
9dd96b9Test User373
16b325cClaude374// Insights (time-travel, dependencies, rollback)
375app.route("/", insightRoutes);
376
f1ab587Claude377// Command center dashboard
378app.route("/", dashboardRoutes);
379
36b4cbdClaude380// Legal pages (terms, privacy, AUP)
381app.route("/", legalRoutes);
382
bdbd0deClaude383// GitHub import / migration
384app.route("/", importRoutes);
14c3cc8Claude385app.route("/", importBulkRoutes);
f390cfaCC LABS App386app.route("/", importSecretsRoutes);
14c3cc8Claude387app.route("/", migrationRoutes);
388
389// Spec-to-PR (experimental AI-generated draft PRs)
390app.route("/", specsRoutes);
bdbd0deClaude391
c81ab7aClaude392// Explore page
393app.route("/", exploreRoutes);
394
59b6fb2Claude395// Onboarding
396app.route("/", onboardingRoutes);
397
0316dbbClaude398// Admin + feature routes
399app.route("/", adminRoutes);
509c376Claude400app.route("/", adminIntegrationsRoutes);
f764c07Claude401app.route("/", adminDeploysRoutes);
402app.route("/", adminDeploysPageRoutes);
9dd96b9Test User403// Note: adminOpsRoutes is mounted earlier (before insightRoutes) — see comment above.
0316dbbClaude404app.route("/", advisoriesRoutes);
405app.route("/", aiChangelogRoutes);
406app.route("/", aiExplainRoutes);
407app.route("/", aiTestsRoutes);
408app.route("/", askRoutes);
409app.route("/", billingRoutes);
6778ad2Claude410app.route("/", stripeWebhookRoutes);
0316dbbClaude411app.route("/", codeScanningRoutes);
412app.route("/", commitStatusesRoutes);
413app.route("/", copilotRoutes);
414app.route("/", depUpdaterRoutes);
415app.route("/", depsRoutes);
416app.route("/", discussionsRoutes);
417app.route("/", environmentsRoutes);
418app.route("/", followsRoutes);
419app.route("/", gatesRoutes);
420app.route("/", gistsRoutes);
421app.route("/", graphqlRoutes);
2c2163eClaude422app.route("/", mcpRoutes);
0316dbbClaude423app.route("/", marketplaceRoutes);
424app.route("/", mergeQueueRoutes);
425app.route("/", mirrorsRoutes);
426app.route("/", orgInsightsRoutes);
427app.route("/", packagesRoutes);
428app.route("/", packagesApiRoutes);
429app.route("/", pagesRoutes);
430app.route("/", projectsRoutes);
431app.route("/", protectedTagsRoutes);
432app.route("/", pwaRoutes);
46d6165Claude433app.route("/", installRoutes);
cd4f63bTest User434// BLOCK Q1 — /gluecron.dxt download (Claude Desktop one-click extension)
435app.route("/", dxtRoutes);
662ce86Claude436// Connect Claude — user-facing one-click MCP setup (/connect/claude). Mounted
437// next to the other one-click flows (install.sh + .dxt) for surface symmetry.
438app.route("/", connectClaudeRoutes);
0316dbbClaude439app.route("/", releasesRoutes);
440app.route("/", requiredChecksRoutes);
441app.route("/", rulesetsRoutes);
442app.route("/", searchRoutes);
443app.route("/", semanticSearchRoutes);
444app.route("/", signingKeysRoutes);
445app.route("/", sponsorsRoutes);
446app.route("/", ssoRoutes);
46d6165Claude447app.route("/", githubOauthRoutes);
582cdacClaude448app.route("/", googleOauthRoutes);
0316dbbClaude449app.route("/", symbolsRoutes);
450app.route("/", templatesRoutes);
451app.route("/", trafficRoutes);
452app.route("/", wikisRoutes);
453app.route("/", workflowsRoutes);
5ff9cc2Claude454app.route("/", workflowArtifactsRoutes);
455app.route("/", workflowSecretsRoutes);
46d6165Claude456app.route("/", sleepModeRoutes);
52ad8b1Claude457app.route("/", vsGithubRoutes);
0316dbbClaude458
cd4f63bTest User459// Block Q3 — Anonymous playground (`/play`, `/play/claim`). Mounted
460// before the web catch-all so the bare `/play` literal wins over the
461// `/:owner` user-profile route.
462app.route("/", playgroundRoutes);
463
79136bbClaude464// Web UI (catch-all, must be last)
465app.route("/", webRoutes);
466
c63b860Claude467// Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so
468// the markup stays consistent with /500 and the admin /403 page.
79136bbClaude469app.notFound((c) => {
36cc17aClaude470 const user = c.get("user") ?? null;
79136bbClaude471 return c.html(
c63b860Claude472 <NotFoundPage user={user} method={c.req.method} path={c.req.path} />,
79136bbClaude473 404
474 );
475});
476
c63b860Claude477// Global error handler — BLOCK O2 uses the shared `ServerErrorPage`
478// view. Trace block only shown outside production.
79136bbClaude479app.onError((err, c) => {
80bed05Claude480 reportError(err, {
481 requestId: c.get("requestId"),
482 path: c.req.path,
483 method: c.req.method,
484 });
c63b860Claude485 // Prefer the inbound `x-request-id` header (LB-supplied) and fall
486 // back to the context value set by request-context middleware.
487 const requestId =
488 c.req.header("x-request-id") ||
489 ((c.get("requestId" as never) as string | undefined) ?? undefined);
36cc17aClaude490 const user = c.get("user") ?? null;
c63b860Claude491 const trace =
492 process.env.NODE_ENV !== "production" && err && err.message
493 ? err.message
494 : undefined;
79136bbClaude495 return c.html(
c63b860Claude496 <ServerErrorPage user={user} requestId={requestId} trace={trace} />,
79136bbClaude497 500
498 );
499});
500
501export default app;