import { publicStatsResponseSchema, type PublicStatsResponse, } from "@turbostarter/api/schema"; import { handle } from "@turbostarter/api/utils"; import { api } from "~/lib/api/server"; const ZERO_STATS: PublicStatsResponse = { messagesRouted: 0, meshesCreated: 0, peersActive: 0, lastUpdated: new Date(0).toISOString(), }; const fetchStats = async (): Promise => { try { return await handle(api.public.stats.$get, { schema: publicStatsResponseSchema, })(); } catch { return ZERO_STATS; } }; const nf = new Intl.NumberFormat("en-US"); export const MeshStats = async () => { const stats = await fetchStats(); const empty = stats.messagesRouted === 0; return (
ciphertext routed {empty ? ( ready to route ) : ( <> {nf.format(stats.messagesRouted)} messages · {nf.format(stats.meshesCreated)} meshes · {nf.format(stats.peersActive)} peers online )}

broker sees none of it

); };