import Router from "koa-router";
import { wantComment, wantEssay } from "src/systems/want";

const router = new Router();

router.get("/:wantVariety/:wantInput/:page", async (ctx) => {
  const {
    params: { wantVariety, wantInput, page },
  } = ctx;

  switch (wantVariety) {
    case "essay":
      ctx.body = await wantEssay(wantInput, Number(page), 10);
      ctx.status = 200;
      break;
    case "comment":
      ctx.body = await wantComment(wantInput, Number(page), 10);
      ctx.status = 200;
      break;
  }
});

export default router;
