Newer
Older
taehui / taehui-fe / src / app / www / avatar / totem / route.ts
@Taehui Taehui on 6 Apr 1 KB 2024-04-07 오전 8:25
import { wipeTotem } from "@/app/www/logic/avatar";
import logIP from "@/app/www/media/logIP";
import validateMillis from "@/app/www/media/validateMillis";
import validateTotem from "@/app/www/media/validateTotem";

export const PATCH = logIP(
  validateMillis(
    validateTotem(async ({ headers }) => {
      return Response.json(
        {
          avatarID: headers.get("avatarID"),
          avatarName: decodeURIComponent(headers.get("avatarName") as string),
          level: Number(headers.get("level")),
          fax: decodeURIComponent(headers.get("fax") as string),
          avatarIntro: decodeURIComponent(headers.get("avatarIntro") as string),
        },
        { status: 201 },
      );
    }),
  ),
);

export const DELETE = logIP(
  validateMillis(
    validateTotem(async ({ headers }) => {
      const totem = headers.get("totem") as string;
      const avatarID = headers.get("avatarID") as string;

      await wipeTotem(avatarID, totem);
      return new Response(undefined, {
        status: 204,
      });
    }),
  ),
);