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