2024-02-10 00:37:48 -06:00
|
|
|
import type { NextApiRequest, NextApiResponse } from "next";
|
|
|
|
import verifyUser from "@/lib/api/verifyUser";
|
|
|
|
import deleteLinksById from "@/lib/api/controllers/links/bulk/deleteLinksById";
|
2024-02-10 01:38:19 -06:00
|
|
|
import updateLinksById from "@/lib/api/controllers/links/bulk/updateLinksById";
|
2024-02-10 00:37:48 -06:00
|
|
|
|
|
|
|
export default async function links(req: NextApiRequest, res: NextApiResponse) {
|
|
|
|
const user = await verifyUser({ req, res });
|
|
|
|
if (!user) return;
|
|
|
|
|
2024-02-10 01:38:19 -06:00
|
|
|
if (req.method === "PUT") {
|
|
|
|
const updated = await updateLinksById(user.id, req.body.linkIds, req.body.data);
|
|
|
|
return res.status(updated.status).json({
|
|
|
|
response: updated.response,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else if (req.method === "DELETE") {
|
2024-02-10 00:37:48 -06:00
|
|
|
const deleted = await deleteLinksById(user.id, req.body.linkIds);
|
|
|
|
return res.status(deleted.status).json({
|
|
|
|
response: deleted.response,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|