mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
feat: added backend stuff
This commit is contained in:
28
packages/lib/server-only/webhooks/create-webhook.ts
Normal file
28
packages/lib/server-only/webhooks/create-webhook.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { prisma } from '@documenso/prisma';
|
||||
import type { WebhookTriggerEvents } from '@documenso/prisma/client';
|
||||
|
||||
export interface CreateWebhookOptions {
|
||||
webhookUrl: string;
|
||||
eventTriggers: WebhookTriggerEvents[];
|
||||
secret: string | null;
|
||||
enabled: boolean;
|
||||
userId: number;
|
||||
}
|
||||
|
||||
export const createWebhook = async ({
|
||||
webhookUrl,
|
||||
eventTriggers,
|
||||
secret,
|
||||
enabled,
|
||||
userId,
|
||||
}: CreateWebhookOptions) => {
|
||||
return await prisma.webhook.create({
|
||||
data: {
|
||||
webhookUrl,
|
||||
eventTriggers,
|
||||
secret,
|
||||
enabled,
|
||||
userId,
|
||||
},
|
||||
});
|
||||
};
|
||||
@ -0,0 +1,9 @@
|
||||
import { prisma } from '@documenso/prisma';
|
||||
|
||||
export const getWebhooksByUserId = async (userId: number) => {
|
||||
return await prisma.webhook.findMany({
|
||||
where: {
|
||||
userId,
|
||||
},
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user