mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
feat: add zapier support
This commit is contained in:
26
packages/lib/server-only/webhooks/zapier/unsubscribe.ts
Normal file
26
packages/lib/server-only/webhooks/zapier/unsubscribe.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import type { NextApiRequest, NextApiResponse } from 'next';
|
||||
|
||||
import { prisma } from '@documenso/prisma';
|
||||
|
||||
import { validateApiToken } from './validateApiToken';
|
||||
|
||||
export const unsubscribeHandler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
try {
|
||||
const { authorization } = req.headers;
|
||||
const { webhookId } = req.body;
|
||||
const user = await validateApiToken({ authorization });
|
||||
|
||||
const deletedWebhook = await prisma.webhook.delete({
|
||||
where: {
|
||||
id: webhookId,
|
||||
userId: user.id,
|
||||
},
|
||||
});
|
||||
|
||||
return res.status(200).json(deletedWebhook);
|
||||
} catch (err) {
|
||||
return res.status(500).json({
|
||||
message: 'Internal Server Error',
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user