- 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>
33 lines
No EOL
935 B
TypeScript
33 lines
No EOL
935 B
TypeScript
import type { RequestHandler } from './$types'
|
|
import { searchAlbumsAndSongs } from '$lib/server/apple-music-client'
|
|
import { dev } from '$app/environment'
|
|
|
|
export const POST: RequestHandler = async ({ request }) => {
|
|
// Only allow in development
|
|
if (!dev) {
|
|
return new Response('Not found', { status: 404 })
|
|
}
|
|
|
|
try {
|
|
const { query, storefront } = await request.json()
|
|
|
|
if (!query) {
|
|
return new Response('Query is required', { status: 400 })
|
|
}
|
|
|
|
// Perform the search
|
|
const results = await searchAlbumsAndSongs(query, 25, storefront || 'us')
|
|
|
|
return new Response(JSON.stringify(results), {
|
|
headers: { 'Content-Type': 'application/json' }
|
|
})
|
|
} catch (error) {
|
|
console.error('Apple Music search error:', error)
|
|
return new Response(JSON.stringify({
|
|
error: error instanceof Error ? error.message : 'Unknown error'
|
|
}), {
|
|
status: 500,
|
|
headers: { 'Content-Type': 'application/json' }
|
|
})
|
|
}
|
|
} |