2023-05-29 14:40:23 -05:00
|
|
|
import getCollection from "@/lib/api/controllers/public/getCollection";
|
2023-06-14 17:34:54 -05:00
|
|
|
import { PublicLinkRequestQuery } from "@/types/global";
|
2023-05-29 14:40:23 -05:00
|
|
|
import type { NextApiRequest, NextApiResponse } from "next";
|
|
|
|
|
2023-06-09 17:31:14 -05:00
|
|
|
export default async function collections(
|
|
|
|
req: NextApiRequest,
|
|
|
|
res: NextApiResponse
|
|
|
|
) {
|
2023-06-14 17:34:54 -05:00
|
|
|
const query: PublicLinkRequestQuery = req.query;
|
2023-05-29 14:40:23 -05:00
|
|
|
|
2023-06-14 17:34:54 -05:00
|
|
|
if (!query) {
|
2023-05-29 14:40:23 -05:00
|
|
|
return res
|
|
|
|
.status(401)
|
|
|
|
.json({ response: "Please choose a valid collection." });
|
|
|
|
}
|
|
|
|
|
|
|
|
if (req.method === "GET") {
|
2023-06-14 17:34:54 -05:00
|
|
|
const collection = await getCollection(query);
|
2023-05-29 14:40:23 -05:00
|
|
|
return res
|
|
|
|
.status(collection.status)
|
|
|
|
.json({ response: collection.response });
|
|
|
|
}
|
|
|
|
}
|