mirror of
https://github.com/DerTyp7/explainegy-nextjs.git
synced 2025-10-29 21:02:13 +01:00
refactor
This commit is contained in:
@@ -1,14 +1,32 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
import { Prisma, PrismaClient } from "@prisma/client";
|
||||
|
||||
|
||||
declare global {
|
||||
namespace NodeJS {
|
||||
interface Global {
|
||||
prisma: PrismaClient;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let prisma: PrismaClient;
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
prisma = new PrismaClient();
|
||||
} else {
|
||||
if (!global.prisma) {
|
||||
global.prisma = new PrismaClient();
|
||||
if (typeof window === "undefined") {
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
prisma = new PrismaClient();
|
||||
} else {
|
||||
// @ts-ignore
|
||||
if (!global.prisma) {
|
||||
// @ts-ignore
|
||||
global.prisma = new PrismaClient();
|
||||
}
|
||||
// @ts-ignore
|
||||
prisma = global.prisma;
|
||||
}
|
||||
prisma = global.prisma;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
export default prisma;
|
||||
|
||||
export type CategoryWithIncludes = Prisma.CategoryGetPayload<{ include: { articles: true, svg: true } }>
|
||||
export type ArticleWithIncludes = Prisma.ArticleGetPayload<{ include: { category: true } }>
|
||||
|
||||
Reference in New Issue
Block a user