import { PrismaClient } from '@prisma/client' import { NextRequest, NextResponse } from 'next/server' const prisma = new PrismaClient() export async function GET( req: NextRequest, { params }: { params: Promise<{ slug: string }> } ) { try { const { slug } = await params const channel = await prisma.channel.findUnique({ where: { slug }, include: { user: true, stats: true, streams: { where: { isArchived: true }, orderBy: { createdAt: 'desc' }, take: 10, }, _count: { select: { followers: true, subscriptions: true, }, }, }, }) if (!channel) { return NextResponse.json({ error: 'Channel not found' }, { status: 404 }) } return NextResponse.json(channel, { status: 200 }) } catch (error) { console.error('Error fetching channel:', error) return NextResponse.json( { error: 'Failed to fetch channel' }, { status: 500 } ) } }