Files
otunes/apps/web/app/api/artist/[id]/cover/route.ts
T

21 lines
574 B
TypeScript

import { api } from "@/convex/_generated/api"
import type { Id } from "@/convex/_generated/dataModel"
import { getConvexClient } from "@/lib/convex-server"
import { serveCoverFile } from "@/lib/serve-cover"
export async function GET(
_request: Request,
{ params }: { params: Promise<{ id: string }> }
) {
const { id } = await params
try {
const artist = await getConvexClient().query(api.library.getArtist, {
id: id as Id<"artists">,
})
return serveCoverFile(artist?.cover)
} catch {
return new Response("Not found", { status: 404 })
}
}