added zod for post requests

This commit is contained in:
daniel31x13
2024-09-14 16:00:19 -04:00
parent a5b1952e0d
commit 1cf7421b76
24 changed files with 350 additions and 180 deletions
+4 -7
View File
@@ -1,13 +1,10 @@
import { LinkIncludingShortenedCollectionAndTags } from "@/types/global";
import { prisma } from "./db";
import getPermission from "./getPermission";
import { UsersAndCollections } from "@prisma/client";
import { PostLinkSchemaType } from "../shared/schemaValidation";
const setLinkCollection = async (
link: LinkIncludingShortenedCollectionAndTags,
userId: number
) => {
if (link?.collection?.id && typeof link?.collection?.id === "number") {
const setLinkCollection = async (link: PostLinkSchemaType, userId: number) => {
if (link.collection?.id && typeof link.collection?.id === "number") {
const existingCollection = await prisma.collection.findUnique({
where: {
id: link.collection.id,
@@ -29,7 +26,7 @@ const setLinkCollection = async (
return null;
return existingCollection;
} else if (link?.collection?.name) {
} else if (link.collection?.name) {
if (link.collection.name === "Unorganized") {
const firstTopLevelUnorganizedCollection =
await prisma.collection.findFirst({