From 6042e305a3cb95ac6da2d259e6a344506fee5a3a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 31 May 2022 16:46:06 +0200 Subject: [PATCH] Rename the Prisma client to `database` --- pages/api/events/[slug].ts | 4 ++-- pages/api/events/mine.ts | 4 ++-- pages/api/login/index.ts | 6 +++--- utils/TelegramLoginDataClass.ts | 2 +- utils/authorizeUser.ts | 4 ++-- utils/prismaClient.ts | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pages/api/events/[slug].ts b/pages/api/events/[slug].ts index 3073f0c..117548e 100644 --- a/pages/api/events/[slug].ts +++ b/pages/api/events/[slug].ts @@ -1,4 +1,4 @@ -import { client } from "../../../utils/prismaClient"; +import { database } from "../../../utils/prismaClient"; import { NextApiRequest, NextApiResponse } from "next"; import { ApiResult } from "../../../types/api"; import { Model, restInPeace } from "../../../utils/restInPeace"; @@ -31,7 +31,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse< } await restInPeace(req, res, { - model: client.event, + model: database.event, retrieve: {which}, create: {create}, upsert: {which, create, update, before: canEdit}, diff --git a/pages/api/events/mine.ts b/pages/api/events/mine.ts index 4cc3198..f8936d1 100644 --- a/pages/api/events/mine.ts +++ b/pages/api/events/mine.ts @@ -1,4 +1,4 @@ -import { client } from "../../../utils/prismaClient"; +import { database } from "../../../utils/prismaClient"; import { NextApiRequest, NextApiResponse } from "next"; import { ApiResult } from "../../../types/api"; import { restInPeace } from "../../../utils/restInPeace"; @@ -16,7 +16,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse< } await restInPeace(req, res, { - model: client.event, + model: database.event, list: {where} }) }) diff --git a/pages/api/login/index.ts b/pages/api/login/index.ts index 4dcd863..d11514a 100644 --- a/pages/api/login/index.ts +++ b/pages/api/login/index.ts @@ -1,5 +1,5 @@ import { NextApiRequest, NextApiResponse } from "next" -import { client } from "../../../utils/prismaClient" +import { database } from "../../../utils/prismaClient" import { TelegramLoginDataClass } from "../../../utils/TelegramLoginDataClass" import { default as cryptoRandomString } from "crypto-random-string" import { ApiResult } from "../../../types/api" @@ -54,7 +54,7 @@ async function loginTelegram(req: NextApiRequest, res: NextApiResponse { throw new Interrupt(401, {error: "Invalid Authorization header" }) } - const dbToken = await client.token.findUnique({where: {token}, include: {user: true}}) + const dbToken = await database.token.findUnique({where: {token}, include: {user: true}}) if(!(dbToken)) { throw new Interrupt(401, {error: "No such Authorization token" }) diff --git a/utils/prismaClient.ts b/utils/prismaClient.ts index 8b8c42f..08416d7 100644 --- a/utils/prismaClient.ts +++ b/utils/prismaClient.ts @@ -1,3 +1,3 @@ import { PrismaClient } from "@prisma/client"; -export const client = new PrismaClient() +export const database = new PrismaClient()