jedmund-svelte/src/routes/api/admin/debug/redis-keys/+server.ts
Justin Edmund f1d0453b63 feat: add comprehensive debug panel for development
- Create DebugPanel component with Now Playing, Albums, and Cache tabs
- Show real-time connection status and update intervals
- Display detailed Apple Music data for each album
- Add inline cache clearing for individual albums
- Implement Apple Music search modal for testing queries
- Add admin endpoints for cache management and API testing
- Only visible in development mode

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-10 21:32:59 -07:00

41 lines
No EOL
1.1 KiB
TypeScript

import type { RequestHandler } from './$types'
import redis from '../../../redis-client'
import { dev } from '$app/environment'
export const GET: RequestHandler = async ({ url }) => {
// Only allow in development
if (!dev) {
return new Response('Not found', { status: 404 })
}
try {
const pattern = url.searchParams.get('pattern') || '*'
// Get all keys matching pattern
const keys = await redis.keys(pattern)
// Get values for each key (limit to first 100 to avoid overload)
const keysWithValues = await Promise.all(
keys.slice(0, 100).map(async (key) => {
const value = await redis.get(key)
const ttl = await redis.ttl(key)
return {
key,
value: value ? (value.length > 200 ? value.substring(0, 200) + '...' : value) : null,
ttl
}
})
)
return new Response(JSON.stringify({
total: keys.length,
showing: keysWithValues.length,
keys: keysWithValues
}), {
headers: { 'Content-Type': 'application/json' }
})
} catch (error) {
console.error('Failed to get Redis keys:', error)
return new Response('Internal server error', { status: 500 })
}
}