Finished editing links

This commit is contained in:
Isaac Wise
2024-02-10 16:23:59 -06:00
parent e1ef638f0e
commit 080be856cc
8 changed files with 61 additions and 119 deletions
-22
View File
@@ -1,22 +0,0 @@
import type { NextApiRequest, NextApiResponse } from "next";
import verifyUser from "@/lib/api/verifyUser";
import deleteLinksById from "@/lib/api/controllers/links/bulk/deleteLinksById";
import updateLinksById from "@/lib/api/controllers/links/bulk/updateLinks";
export default async function links(req: NextApiRequest, res: NextApiResponse) {
const user = await verifyUser({ req, res });
if (!user) return;
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") {
const deleted = await deleteLinksById(user.id, req.body.linkIds);
return res.status(deleted.status).json({
response: deleted.response,
});
}
}
+2 -1
View File
@@ -5,6 +5,7 @@ import { LinkRequestQuery } from "@/types/global";
import verifyUser from "@/lib/api/verifyUser";
import deleteLinksById from "@/lib/api/controllers/links/bulk/deleteLinksById";
import updateLinksById from "@/lib/api/controllers/links/bulk/updateLinks";
import updateLinks from "@/lib/api/controllers/links/bulk/updateLinks";
export default async function links(req: NextApiRequest, res: NextApiResponse) {
const user = await verifyUser({ req, res });
@@ -42,7 +43,7 @@ export default async function links(req: NextApiRequest, res: NextApiResponse) {
response: newlink.response,
});
} else if (req.method === "PUT") {
const updated = await updateLinksById(user.id, req.body.linkIds, req.body.data);
const updated = await updateLinks(user.id, req.body.links, req.body.newData);
return res.status(updated.status).json({
response: updated.response,
});