feat: test webhook functionality (#1886)

This commit is contained in:
Catalin Pit
2025-07-14 08:13:56 +03:00
committed by GitHub
parent ca9a70ced5
commit 122e25b491
9 changed files with 808 additions and 32 deletions

View File

@ -3,6 +3,7 @@ import { deleteWebhookById } from '@documenso/lib/server-only/webhooks/delete-we
import { editWebhook } from '@documenso/lib/server-only/webhooks/edit-webhook';
import { getWebhookById } from '@documenso/lib/server-only/webhooks/get-webhook-by-id';
import { getWebhooksByTeamId } from '@documenso/lib/server-only/webhooks/get-webhooks-by-team-id';
import { triggerTestWebhook } from '@documenso/lib/server-only/webhooks/trigger-test-webhook';
import { authenticatedProcedure, router } from '../trpc';
import {
@ -11,6 +12,7 @@ import {
ZEditWebhookRequestSchema,
ZGetTeamWebhooksRequestSchema,
ZGetWebhookByIdRequestSchema,
ZTriggerTestWebhookRequestSchema,
} from './schema';
export const webhookRouter = router({
@ -106,4 +108,25 @@ export const webhookRouter = router({
teamId,
});
}),
testWebhook: authenticatedProcedure
.input(ZTriggerTestWebhookRequestSchema)
.mutation(async ({ input, ctx }) => {
const { id, event, teamId } = input;
ctx.logger.info({
input: {
id,
event,
teamId,
},
});
return await triggerTestWebhook({
id,
event,
userId: ctx.user.id,
teamId,
});
}),
});