21 lines
570 B
TypeScript
21 lines
570 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 album = await getConvexClient().query(api.library.getAlbum, {
|
|
id: id as Id<"albums">,
|
|
})
|
|
return serveCoverFile(album?.cover)
|
|
} catch {
|
|
return new Response("Not found", { status: 404 })
|
|
}
|
|
}
|