Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/llms-txt-hub / apps/web/app/api/debug/clear-redis-cache/route.ts |
| Date | Not specified in source |
| Repository | Janady13/llms-txt-hub |
| Revision | e0f4bf978d4df168369c7601d9c5f5ea89e84377 |
| Branch | main |
| Path or archive member | apps/web/app/api/debug/clear-redis-cache/route.ts |
| Original SHA-256 | bf496ebc59669f0083316f17781347a6e78d6c5ba1ab02f724e1f4cc1315b398 |
| Git blob SHA | 2a9cc5a12433f7a884aaaa7a715c682b9680fe51 |
| Reading-copy SHA-256 | bf496ebc59669f0083316f17781347a6e78d6c5ba1ab02f724e1f4cc1315b398 |
Recovered source transcript
Download complete source text ↓57 lines · 1.7 KB
import { logger } from '@thedaviddias/logging'
import { type NextRequest, NextResponse } from 'next/server'
import { ensureDebugAccess } from '@/app/api/debug/_utils'
import { CACHE_KEYS, del } from '@/lib/redis'
/**
* POST handler for clearing Redis cache for a specific user
*
* @param request - NextRequest containing username in body
* @returns Promise resolving to NextResponse with cache clear result or error
*/
export async function POST(request: NextRequest) {
const access = await ensureDebugAccess(request)
if (!access.ok) {
return access.response
}
try {
const body = await request.json()
const { username } = body
if (!username) {
return NextResponse.json({ error: 'Username parameter required' }, { status: 400 })
}
const cacheKey = `${CACHE_KEYS.GITHUB_CONTRIBUTIONS}${username}`
const deleted = await del(cacheKey)
logger.info('Debug: Clearing Redis cache for contributions', {
data: { username, cacheKey, deleted },
tags: { type: 'debug', component: 'redis-cache' }
})
return NextResponse.json({
username,
cacheKey,
deleted,
message: deleted ? 'Cache cleared successfully' : 'Cache was not found or already cleared',
timestamp: new Date().toISOString()
})
} catch (error) {
logger.error('Debug: Error clearing Redis cache', {
data: { error: error instanceof Error ? error.message : 'Unknown error' },
tags: { type: 'debug', component: 'redis-cache', error: 'clear-failed' }
})
return NextResponse.json(
{
error: 'Failed to clear Redis cache',
details: error instanceof Error ? error.message : 'Unknown error',
timestamp: new Date().toISOString()
},
{ status: 500 }
)
}
}