(req: NextRequest)
| 6 | export const dynamic = "force-dynamic"; |
| 7 | |
| 8 | export async function GET(req: NextRequest) { |
| 9 | if (req.method === 'GET') { |
| 10 | try { |
| 11 | const url = new URL(req.url); |
| 12 | const song_id = url.searchParams.get('song_id'); |
| 13 | |
| 14 | if (!song_id) { |
| 15 | return new NextResponse(JSON.stringify({ error: 'Song ID is required' }), { |
| 16 | status: 400, |
| 17 | headers: { |
| 18 | 'Content-Type': 'application/json', |
| 19 | ...corsHeaders |
| 20 | } |
| 21 | }); |
| 22 | } |
| 23 | |
| 24 | const lyricAlignment = await (await sunoApi((await cookies()).toString())).getLyricAlignment(song_id); |
| 25 | |
| 26 | |
| 27 | return new NextResponse(JSON.stringify(lyricAlignment), { |
| 28 | status: 200, |
| 29 | headers: { |
| 30 | 'Content-Type': 'application/json', |
| 31 | ...corsHeaders |
| 32 | } |
| 33 | }); |
| 34 | } catch (error) { |
| 35 | console.error('Error fetching lyric alignment:', error); |
| 36 | |
| 37 | return new NextResponse(JSON.stringify({ error: 'Internal server error. ' + error }), { |
| 38 | status: 500, |
| 39 | headers: { |
| 40 | 'Content-Type': 'application/json', |
| 41 | ...corsHeaders |
| 42 | } |
| 43 | }); |
| 44 | } |
| 45 | } else { |
| 46 | return new NextResponse('Method Not Allowed', { |
| 47 | headers: { |
| 48 | Allow: 'GET', |
| 49 | ...corsHeaders |
| 50 | }, |
| 51 | status: 405 |
| 52 | }); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | export async function OPTIONS(request: Request) { |
| 57 | return new Response(null, { |
nothing calls this directly
no test coverage detected