CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
public-stats.ts
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| 52ad8b1 | 1 | /** |
| 2 | * Block L4 — Public stats API endpoint. | |
| 3 | * | |
| 4 | * GET /api/v2/stats | |
| 5 | * | |
| 6 | * Public, no auth, CORS-open (inherits `/api/*` cors from `app.tsx`). | |
| 7 | * Returns the same `PublicStats` JSON shape rendered on the marketing | |
| 8 | * landing page. Cached at the lib layer (5 min in-memory LRU); the | |
| 9 | * response carries `Cache-Control: public, max-age=300` so CDN / | |
| 10 | * browser caches can hold it too. | |
| 11 | * | |
| 12 | * The handler never throws — `computePublicStats` degrades to all-zeros | |
| 13 | * on DB error, so a 200 with zeros is the worst case here. | |
| 14 | */ | |
| 15 | ||
| 16 | import { Hono } from "hono"; | |
| 17 | import { computePublicStats } from "../lib/public-stats"; | |
| 18 | ||
| 19 | const publicStats = new Hono(); | |
| 20 | ||
| 21 | publicStats.get("/api/v2/stats", async (c) => { | |
| 22 | const stats = await computePublicStats(); | |
| 23 | c.header("cache-control", "public, max-age=300"); | |
| 24 | return c.json({ | |
| 25 | ...stats, | |
| 26 | asOf: stats.asOf.toISOString(), | |
| 27 | }); | |
| 28 | }); | |
| 29 | ||
| 30 | export default publicStats; |