Merge branch 'main' into feat/document-auth

This commit is contained in:
David Nguyen
2024-03-25 23:06:46 +08:00
56 changed files with 4919 additions and 1306 deletions

View File

@ -30,6 +30,27 @@ export interface GetDocumentAndRecipientByTokenOptions {
*/
requireAccessAuth?: boolean;
}
export type GetDocumentByTokenOptions = {
token: string;
};
export const getDocumentByToken = async ({ token }: GetDocumentByTokenOptions) => {
if (!token) {
throw new Error('Missing token');
}
const result = await prisma.document.findFirstOrThrow({
where: {
Recipient: {
some: {
token,
},
},
},
});
return result;
};
export type DocumentAndSender = Awaited<ReturnType<typeof getDocumentAndSenderByToken>>;