import { wantComment, wantEssay } from "@/app/www/logic/want";
import logIP from "@/app/www/media/logIP";

export const GET = logIP(
  async (
    { nextUrl: { searchParams } },
    { params: { wantVariety, wantInput } },
  ) => {
    const page = Number(searchParams.get("page") ?? "1");

    switch (wantVariety) {
      case "essay":
        return Response.json(await wantEssay(wantInput, page));
      case "comment":
        return Response.json(await wantComment(wantInput, page));
      default:
        return new Response(undefined, { status: 400 });
    }
  },
);
