chore: refactor code

This commit is contained in:
Catalin Pit
2024-02-27 15:22:02 +02:00
parent af30443f5a
commit f0a511e238
5 changed files with 37 additions and 18 deletions

View File

@@ -10,7 +10,7 @@ export const subscribeHandler = async (req: NextApiRequest, res: NextApiResponse
const { webhookUrl, eventTrigger } = req.body;
const user = await validateApiToken({ authorization });
const result = await validateApiToken({ authorization });
const createdWebhook = await prisma.webhook.create({
data: {
@@ -18,7 +18,8 @@ export const subscribeHandler = async (req: NextApiRequest, res: NextApiResponse
eventTriggers: [eventTrigger],
secret: null,
enabled: true,
userId: user.id,
userId: result.userId ? result.userId : result.user.id,
teamId: result.userId ? undefined : result.teamId,
},
});