project-standalo-sonic-cloud/app/api/labels/[id]/artists/route.ts

41 lines
893 B
TypeScript

import { NextRequest, NextResponse } from 'next/server'
import { prisma } from '@/lib/prisma'
export async function GET(
request: NextRequest,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params
const artists = await prisma.artist.findMany({
where: {
labelId: id,
},
include: {
user: {
select: {
email: true,
username: true,
displayName: true,
},
},
_count: {
select: {
songs: true,
albums: true,
},
},
},
orderBy: {
createdAt: 'desc',
},
})
return NextResponse.json(artists)
} catch (error) {
console.error('Error fetching label artists:', error)
return NextResponse.json({ error: 'Failed to fetch label artists' }, { status: 500 })
}
}