Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/llms-txt-hub / apps/web/app/api/cli/stats/[slug]/route.ts |
| Date | Not specified in source |
| Repository | Janady13/llms-txt-hub |
| Revision | e0f4bf978d4df168369c7601d9c5f5ea89e84377 |
| Branch | main |
| Path or archive member | apps/web/app/api/cli/stats/[slug]/route.ts |
| Original SHA-256 | 42730744431637bb3507eb3f831da510bdf55764202c7c7696120f5add9c382a |
| Git blob SHA | ea257eb2d9e6071ffcc1f912d4eaedc1758dc2f7 |
| Reading-copy SHA-256 | 42730744431637bb3507eb3f831da510bdf55764202c7c7696120f5add9c382a |
Recovered source transcript
Download complete source text ↓39 lines · 0.9 KB
import { type NextRequest, NextResponse } from 'next/server'
import { getRawClient } from '@/lib/redis'
/**
* GET /api/cli/stats/[slug]
*
* Returns the total install count for a CLI skill from Redis.
* Falls back to 0 when Redis is unavailable.
*/
export async function GET(
_request: NextRequest,
{ params }: { params: Promise<{ slug: string }> }
) {
const { slug } = await params
if (!slug || typeof slug !== 'string') {
return NextResponse.json({ error: 'Missing slug' }, { status: 400 })
}
const redis = getRawClient()
if (!redis) {
return NextResponse.json({ count: 0 })
}
try {
const count = await redis.hget<number>('telemetry:skills:total', slug)
return NextResponse.json(
{ count: count ?? 0 },
{
headers: {
'Cache-Control': 'public, s-maxage=300, stale-while-revalidate=600'
}
}
)
} catch {
return NextResponse.json({ count: 0 })
}
}