fix: address issues raised in preview PR

This commit is contained in:
Agusti Fernandez Pardo committed 2022-06-24 00:26:40 +02:00
1 parent 9b142640d5
commit 61c82eb197
11 files changed
+16 -15

No files matched your search

+3 -2
View File
@@ -1,6 +1,7 @@
import { PrismaClient, UserPermissionRole } from "@prisma/client";
import { UserPermissionRole } from "@prisma/client";
export const isAdminGuard = async (userId: number, prisma: PrismaClient) => {
export const isAdminGuard = async (req: NextApiRequest) => {
const { userId, prisma } = req;
const user = await prisma.user.findUnique({ where: { id: userId } });
return user?.role === UserPermissionRole.ADMIN;
};
+1 -1
View File
@@ -5,7 +5,7 @@ export type GetSubscriberOptions = {
eventTypeId: number;
triggerEvent: WebhookTriggerEvents;
};
/** @note will this not work with custom prisma? since we're importing prisma directly and not passing it from request here **/
const getWebhooks = async (options: GetSubscriberOptions, prisma: PrismaClient) => {
const { userId, eventTypeId } = options;
const allWebhooks = await prisma.webhook.findMany({