Newer
Older
taehui / taehui-fe / src / app / www / want / [wantVariety] / [textInput] / route.ts
@Taehui Taehui on 17 Mar 662 bytes 2024-03-18 오전 12:51
import logIP from "@/app/www/media/logIP";
import { wantComment, wantEssay } from "@/app/www/logic/want";

export const GET = logIP(
  async (
    { nextUrl: { searchParams } },
    { params: { wantVariety, textInput } },
  ) => {
    const page = searchParams.get("page");
    if (!page) {
      return new Response(undefined, { status: 400 });
    }

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