import { NextRequest, NextResponse } from "next/server";
import { findValidInvite } from "@/lib/invites";

interface RouteContext {
  params: Promise<{ token: string }>;
}

export async function GET(_req: NextRequest, { params }: RouteContext) {
  const { token } = await params;
  const invite = await findValidInvite(token);
  if (!invite) {
    return NextResponse.json({ valid: false });
  }
  return NextResponse.json({ valid: true, email: invite.email });
}
