Enabled webhook create call

This commit is contained in:
Syed Ali Shahbaz authored and Agusti Fernandez Pardo committed 2022-05-27 20:46:22 +02:00
1 parent 6099bfb4ee
commit a945d5a61c
1 file changed
+13 -13
+13 -13
View File
@@ -55,19 +55,19 @@ async function createOrlistAllWebhooks(
* 401:
* description: Authorization information is missing or invalid.
*/
// const safe = schemaWebhookCreateBodyParams.safeParse(body);
// if (!safe.success) {
// res.status(400).json({ message: "Invalid request body" });
// return;
// }
// const data = await prisma.webhook.create({ data: { ...safe.data, userId } });
// if (data) res.status(201).json({ webhook: data, message: "Webhook created successfully" });
// else
// (error: Error) =>
// res.status(400).json({
// message: "Could not create new webhook",
// error,
// });
const safe = schemaWebhookCreateBodyParams.safeParse(body);
if (!safe.success) {
res.status(400).json({ message: "Invalid request body" });
return;
}
const data = await prisma.webhook.create({ data: { ...safe.data, userId } });
if (data) res.status(201).json({ webhook: data, message: "Webhook created successfully" });
else
(error: Error) =>
res.status(400).json({
message: "Could not create new webhook",
error,
});
} else res.status(405).json({ message: `Method ${method} not allowed` });
}