import { NextRequest, NextResponse } from "next/server"; import { prisma } from "@/lib/db"; import { queryRaw } from "@/lib/db"; export async function GET() { const participants = await prisma.participants.findMany({ orderBy: { name: "asc" }, }); return NextResponse.json(participants); } export async function POST(req: NextRequest) { const { name, email } = await req.json(); if (!name?.trim()) { return NextResponse.json({ error: "name required" }, { status: 400 }); } const participant = await prisma.participants.create({ data: { name: name.trim(), email: email?.trim() || null }, }); return NextResponse.json(participant, { status: 201 }); }