A fullstack app for indexing standard.site documents
8
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 38 lines 1.1 kB view raw
1import { Hono } from "hono"; 2import type { Bindings } from "../types"; 3 4const stats = new Hono<{ Bindings: Bindings }>(); 5 6stats.get("/", async (c) => { 7 try { 8 const db = c.env.DB; 9 const [records, pdsCache, recordCache, pubCache] = await Promise.all([ 10 db 11 .prepare("SELECT COUNT(*) as count FROM repo_records") 12 .first<{ count: number }>(), 13 db 14 .prepare("SELECT COUNT(*) as count FROM pds_cache") 15 .first<{ count: number }>(), 16 db 17 .prepare("SELECT COUNT(*) as count FROM record_cache") 18 .first<{ count: number }>(), 19 db 20 .prepare("SELECT COUNT(*) as count FROM publication_cache") 21 .first<{ count: number }>(), 22 ]); 23 24 return c.json({ 25 repo_records: records?.count || 0, 26 pds_cache: pdsCache?.count || 0, 27 record_cache: recordCache?.count || 0, 28 publication_cache: pubCache?.count || 0, 29 }); 30 } catch (error) { 31 return c.json( 32 { error: "Failed to fetch stats", details: String(error) }, 33 500 34 ); 35 } 36}); 37 38export default stats;