initial commit
This commit is contained in:
40
packages/database/src/index.ts
Normal file
40
packages/database/src/index.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
export { PrismaClient, Prisma } from '@prisma/client';
|
||||
export type {
|
||||
User,
|
||||
UserCredential,
|
||||
UserSession,
|
||||
PlatformRole,
|
||||
UserPlatformRole,
|
||||
GameServer,
|
||||
GameServerStateTransition,
|
||||
GameNode,
|
||||
GameNodeHeartbeat,
|
||||
Plan,
|
||||
FeatureFlag,
|
||||
SystemSetting,
|
||||
AuditEvent,
|
||||
JobRecord,
|
||||
} from '@prisma/client';
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const globalForPrisma = globalThis as unknown as {
|
||||
prisma: PrismaClient | undefined;
|
||||
};
|
||||
|
||||
export const prisma =
|
||||
globalForPrisma.prisma ??
|
||||
new PrismaClient({
|
||||
log:
|
||||
process.env['LOG_LEVEL'] === 'debug'
|
||||
? ['query', 'info', 'warn', 'error']
|
||||
: ['warn', 'error'],
|
||||
});
|
||||
|
||||
if (process.env['NODE_ENV'] !== 'production') {
|
||||
globalForPrisma.prisma = prisma;
|
||||
}
|
||||
|
||||
export function createPrismaClient(): PrismaClient {
|
||||
return new PrismaClient();
|
||||
}
|
||||
Reference in New Issue
Block a user