Skip to content

Commit

Permalink
fix(prisma-client): instantiate PrismaClient only once
Browse files Browse the repository at this point in the history
  • Loading branch information
Cali93 committed May 31, 2023
1 parent 3ebffee commit 8aa2e18
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/services/prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import jwt from "jsonwebtoken";
import { SiweMessage } from "siwe";
import {
DEFAULT_INSTANCE_ID,
secureToken,
SEVEN_DAYS_IN_SECONDS,
secureToken,
} from "../utils";
import { GoTrueClaims, TPrismaTransaction } from "../utils/types";

const prisma = new PrismaClient();

export const generateAccessToken = async (
user: users,
expiresIn: number,
Expand Down Expand Up @@ -51,8 +53,6 @@ export const generateAccessToken = async (
};

export async function createOrUpdateUser(siweMsg: SiweMessage) {
const prisma = new PrismaClient();

const tokens = await prisma.$transaction(async (tx) => {
const existingUser = await tx.users.findFirst({
where: {
Expand Down

0 comments on commit 8aa2e18

Please sign in to comment.