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(
|
2023-06-09 17:31:14 -05:00
|
|
|
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 });
|
|
|
|
}
|
|
|
|
}
|