getDocument recfactor, qoc

This commit is contained in:
Timur Ercan
2023-02-01 19:15:43 +01:00
parent f4a6e3c8fc
commit 7a036d8692
7 changed files with 22 additions and 27 deletions

View File

@ -4,12 +4,13 @@ import { Document as PrismaDocument } from "@prisma/client";
export const getDocument = async (
documentId: number,
context: any
req: any,
res: any
): Promise<PrismaDocument> => {
const user = await getUserFromToken(context.req, context.res);
const user = await getUserFromToken(req, res);
if (!user) return Promise.reject("Invalid user or token.");
if (!documentId) Promise.reject("No documentId");
if (!context) Promise.reject("No context");
if (!req || !res) Promise.reject("No res or req");
const document: PrismaDocument = await prisma.document.findFirstOrThrow({
where: {