import { NextResponse } from "next/server";
import { COOKIE_NAME_ADMIN, requireAdminPost } from "@/lib/admin-session";

export async function POST(req: Request) {
  const guard = await requireAdminPost()(req as never);
  if ("response" in guard) return guard.response;

  const res = NextResponse.json({ success: true });
  res.cookies.set({
    name: COOKIE_NAME_ADMIN,
    value: "",
    httpOnly: true,
    secure: process.env.NODE_ENV === "production",
    sameSite: "lax",
    path: "/",
    maxAge: 0,
  });
  return res;
}

