mirror of
https://github.com/documenso/documenso.git
synced 2025-11-21 12:11:29 +10:00
28 lines
537 B
TypeScript
28 lines
537 B
TypeScript
import { prisma } from '@documenso/prisma';
|
|
|
|
export type GetDocumentByAccessTokenOptions = {
|
|
token: string;
|
|
};
|
|
|
|
export const getDocumentByAccessToken = async ({ token }: GetDocumentByAccessTokenOptions) => {
|
|
if (!token) {
|
|
throw new Error('Missing token');
|
|
}
|
|
|
|
const result = await prisma.documentAccessToken.findFirstOrThrow({
|
|
where: {
|
|
token,
|
|
},
|
|
include: {
|
|
document: {
|
|
include: {
|
|
documentData: true,
|
|
documentMeta: true,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
return result;
|
|
};
|