- 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>
55 lines
No EOL
1.7 KiB
TypeScript
55 lines
No EOL
1.7 KiB
TypeScript
import type { RequestHandler } from './$types'
|
|
import { searchAlbumsAndSongs } from '$lib/server/apple-music-client'
|
|
import { dev } from '$app/environment'
|
|
|
|
export const GET: RequestHandler = async () => {
|
|
if (!dev) {
|
|
return new Response('Not found', { status: 404 })
|
|
}
|
|
|
|
// Test simple search
|
|
const searchQuery = '藤井風 Hachikō'
|
|
console.log(`Testing simple search for: ${searchQuery}`)
|
|
|
|
try {
|
|
// Search in both storefronts
|
|
const jpResults = await searchAlbumsAndSongs(searchQuery, 5, 'jp')
|
|
const usResults = await searchAlbumsAndSongs(searchQuery, 5, 'us')
|
|
|
|
// Check if we found the song in either storefront
|
|
const jpSongs = jpResults.results?.songs?.data || []
|
|
const usSongs = usResults.results?.songs?.data || []
|
|
|
|
const hachiko = [...jpSongs, ...usSongs].find(s =>
|
|
s.attributes?.name?.toLowerCase() === 'hachikō' &&
|
|
s.attributes?.artistName?.includes('藤井')
|
|
)
|
|
|
|
return new Response(JSON.stringify({
|
|
searchQuery,
|
|
jpSongsFound: jpSongs.length,
|
|
usSongsFound: usSongs.length,
|
|
hachikoFound: !!hachiko,
|
|
hachikoDetails: hachiko ? {
|
|
name: hachiko.attributes?.name,
|
|
artist: hachiko.attributes?.artistName,
|
|
album: hachiko.attributes?.albumName,
|
|
preview: hachiko.attributes?.previews?.[0]?.url
|
|
} : null,
|
|
allSongs: [...jpSongs, ...usSongs].map(s => ({
|
|
name: s.attributes?.name,
|
|
artist: s.attributes?.artistName,
|
|
album: s.attributes?.albumName
|
|
}))
|
|
}), {
|
|
headers: { 'Content-Type': 'application/json' }
|
|
})
|
|
} catch (error) {
|
|
return new Response(JSON.stringify({
|
|
error: error instanceof Error ? error.message : 'Unknown error'
|
|
}), {
|
|
status: 500,
|
|
headers: { 'Content-Type': 'application/json' }
|
|
})
|
|
}
|
|
} |