import { NextResponse } from 'next/server';
import { requireAuth, toApiErrorResponse } from '@/lib/auth';
import { getManageableGuilds } from '@/lib/guilds';

export async function GET() {
  try {
    const session = await requireAuth();
    const guilds = await getManageableGuilds(session);
    return NextResponse.json({ guilds });
  } catch (error) {
    return toApiErrorResponse(error);
  }
}
