/** * Stats routes — GET /api/stats, GET /api/usage. * * Ports Python's viewer_routes/stats.py. */ import { type MemoryStore } from "@codemem/core"; import { Hono } from "hono"; type UsagePayload = Record; interface UsageCacheEntry { payload: UsagePayload; expiresAtMs: number; } /** * Sweep expired entries and enforce the size cap before inserting a new one. * * Mirrors the lazy-sweep approach in request-rate-limit.ts: eviction is * piggybacked on writes rather than run on a timer, so an idle viewer does no * background work. Expired entries (those past `expiresAtMs`) are always * dropped; if the map is still at capacity afterward — e.g. a burst of * distinct, still-live bypass keys — the oldest-expiring entries are evicted * to make room. This never changes hit/miss semantics for a live entry: the * caller still re-checks `expiresAtMs` on read, and only already-expired or * over-cap entries are removed here. */ declare function sweepUsagePayloadCache(cache: Map, nowMs: number): void; /** * Create stats routes. The store factory is called per-request to get a * fresh connection (matching the Python viewer pattern). */ export declare function statsRoutes(getStore: () => MemoryStore): Hono; /** * Internals exposed for unit tests of the usage-cache eviction. Not part of the * route's public surface; consumers should go through the HTTP handlers. */ export declare const __usageCacheTestHooks: { cache: Map; sweep: typeof sweepUsagePayloadCache; maxEntries: number; ttlMs: number; }; export {}; //# sourceMappingURL=stats.d.ts.map