feat: add field and recipient endpoints

This commit is contained in:
Mythie
2024-01-29 22:53:15 +11:00
parent 5a28eaa4ff
commit 98df273ebc
11 changed files with 720 additions and 8 deletions

View File

@ -0,0 +1,21 @@
import { prisma } from '@documenso/prisma';
export type GetRecipientByEmailOptions = {
documentId: number;
email: string;
};
export const getRecipientByEmail = async ({ documentId, email }: GetRecipientByEmailOptions) => {
const recipient = await prisma.recipient.findFirst({
where: {
documentId,
email: email.toLowerCase(),
},
});
if (!recipient) {
throw new Error('Recipient not found');
}
return recipient;
};