el.xwx.moe/pages/api/v1/public/collections/[id].ts

21 lines
584 B
TypeScript
Raw Normal View History

2023-11-15 12:12:06 -06:00
import getPublicCollection from "@/lib/api/controllers/public/collections/getPublicCollection";
2023-05-29 14:40:23 -05:00
import type { NextApiRequest, NextApiResponse } from "next";
2023-11-19 07:12:37 -06:00
export default async function collection(
req: NextApiRequest,
res: NextApiResponse
) {
2023-11-15 12:12:06 -06:00
if (!req?.query?.id) {
2023-05-29 14:40:23 -05:00
return res
.status(401)
.json({ response: "Please choose a valid collection." });
}
if (req.method === "GET") {
2023-11-15 12:12:06 -06:00
const collection = await getPublicCollection(Number(req?.query?.id));
2023-05-29 14:40:23 -05:00
return res
.status(collection.status)
.json({ response: collection.response });
}
}