import { getServerSession } from 'next-auth';
import { authOptions } from '@/lib/auth';
import { tickets } from '@/lib/db';
import { NextResponse } from 'next/server';

export async function GET(_: Request, { params }: { params: Promise<{ guildId: string }> }) {
  const session = await getServerSession(authOptions);
  if (!session) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });

  const { guildId } = await params;
  return NextResponse.json(tickets.stats(guildId));
}
