mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
29 lines
696 B
TypeScript
29 lines
696 B
TypeScript
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',
|
|
});
|
|
}
|
|
};
|