27 lines
696 B
TypeScript
27 lines
696 B
TypeScript
import { NextResponse } from 'next/server'
|
|
import { navidromeGet } from '@/lib/navidrome'
|
|
|
|
export async function POST(
|
|
request: Request,
|
|
{ params }: { params: Promise<{ id: string }> }
|
|
) {
|
|
const { id } = await params
|
|
|
|
try {
|
|
const { songId } = await request.json()
|
|
if (!songId) {
|
|
return NextResponse.json({ error: 'songId required' }, { status: 400 })
|
|
}
|
|
|
|
await navidromeGet('updatePlaylist.view', {
|
|
playlistId: id,
|
|
songIdToAdd: songId,
|
|
})
|
|
|
|
return NextResponse.json({ success: true })
|
|
} catch (error) {
|
|
console.error('Add to playlist error:', error)
|
|
return NextResponse.json({ error: 'Failed to add to playlist' }, { status: 502 })
|
|
}
|
|
}
|