feat: adds automatic generation of uuid id for webhooks create on API
This commit is contained in:
1 parent
7f42cc8479
commit
43b94d3e96
5 files changed
+7
-6
No files matched your search
@@ -51,7 +51,7 @@ export async function WebhookById(
|
||||
case "GET":
|
||||
await prisma.webhook
|
||||
.findUnique({ where: { id: safeQuery.data.id } })
|
||||
// .then((data) => schemaWebhookReadPublic.parse(data))
|
||||
.then((data) => schemaWebhookReadPublic.parse(data))
|
||||
.then((webhook) => res.status(200).json({ webhook }))
|
||||
.catch((error: Error) =>
|
||||
res.status(404).json({
|
||||
@@ -97,7 +97,7 @@ export async function WebhookById(
|
||||
}
|
||||
await prisma.webhook
|
||||
.update({ where: { id: safeQuery.data.id }, data: safeBody.data })
|
||||
// .then((data) => schemaWebhookReadPublic.parse(data))
|
||||
.then((data) => schemaWebhookReadPublic.parse(data))
|
||||
.then((webhook) => res.status(200).json({ webhook }))
|
||||
.catch((error: Error) =>
|
||||
res.status(404).json({
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
import prisma from "@calcom/prisma";
|
||||
|
||||
@@ -60,7 +61,7 @@ async function createOrlistAllWebhooks(
|
||||
res.status(400).json({ message: "Invalid request body" });
|
||||
return;
|
||||
}
|
||||
const data = await prisma.webhook.create({ data: { ...safe.data, userId } });
|
||||
const data = await prisma.webhook.create({ data: { id: uuidv4(), ...safe.data, userId } });
|
||||
if (data) res.status(201).json({ webhook: data, message: "Webhook created successfully" });
|
||||
else
|
||||
(error: Error) =>
|
||||
|
||||
Reference in new issue
Block a user