File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed
Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change 11import { NextResponse } from 'next/server'
2- import { getCachedAgents } from '@/server/agents-data'
2+ import { getAgentsCount } from '@/server/agents-data'
3+
4+ export const dynamic = 'force-dynamic'
35
46export const GET = async ( ) => {
57 try {
6- // Warm the cache by fetching agents data
7- // This ensures SEO-critical data is available immediately
8- const agents = await getCachedAgents ( )
8+ // Lightweight check: just count agents to avoid caching large payloads
9+ const agentCount = await getAgentsCount ( )
910
1011 return NextResponse . json ( {
1112 status : 'ok' ,
12- cached_agents : agents . length ,
13- timestamp : new Date ( ) . toISOString ( )
13+ agents : agentCount ,
14+ timestamp : new Date ( ) . toISOString ( ) ,
1415 } )
1516 } catch ( error ) {
1617 console . error ( '[Healthz] Failed to warm cache:' , error )
@@ -19,7 +20,7 @@ export const GET = async () => {
1920 return NextResponse . json ( {
2021 status : 'ok' ,
2122 cache_warm : false ,
22- error : error instanceof Error ? error . message : 'Unknown error'
23+ error : error instanceof Error ? error . message : 'Unknown error' ,
2324 } )
2425 }
2526}
Original file line number Diff line number Diff line change @@ -4,6 +4,14 @@ import { unstable_cache } from 'next/cache'
44import { sql , eq , and , gte } from 'drizzle-orm'
55import { buildAgentsData } from './agents-transform'
66
7+ export const getAgentsCount = async ( ) : Promise < number > => {
8+ const result = await db
9+ . select ( { count : sql < number > `COUNT(*)` } )
10+ . from ( schema . agentConfig )
11+
12+ return result [ 0 ] ?. count ?? 0
13+ }
14+
715export interface AgentData {
816 id : string
917 name : string
You can’t perform that action at this time.
0 commit comments