import { requireAuth } from "@/lib/auth";
import { prisma } from "@/lib/db";

export async function GET() {
  try {
    await requireAuth();
    const messages = await prisma.contactMessage.findMany({
      orderBy: { createdAt: "desc" },
    });
    return Response.json(messages);
  } catch {
    return Response.json({ error: "Unauthorized" }, { status: 401 });
  }
}
