zapier webhooks

This commit is contained in:
Catalin Pit
2024-02-23 15:02:53 +02:00
parent 91375a17c2
commit 99a26065a8
13 changed files with 232 additions and 3 deletions

View 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',
});
}
};