project init
This commit is contained in:
36
packages/database/src/index.ts
Normal file
36
packages/database/src/index.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
// Export Prisma Client
|
||||
export * from '@prisma/client';
|
||||
|
||||
// Singleton pattern for Prisma Client
|
||||
const globalForPrisma = globalThis as unknown as {
|
||||
prisma: PrismaClient | undefined;
|
||||
};
|
||||
|
||||
export const prisma =
|
||||
globalForPrisma.prisma ??
|
||||
new PrismaClient({
|
||||
log: process.env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
globalForPrisma.prisma = prisma;
|
||||
}
|
||||
|
||||
// Type exports for convenience
|
||||
export type {
|
||||
User,
|
||||
UserSettings,
|
||||
Subscription,
|
||||
Course,
|
||||
Chapter,
|
||||
Lesson,
|
||||
CourseGeneration,
|
||||
Category,
|
||||
Purchase,
|
||||
Review,
|
||||
} from '@prisma/client';
|
||||
|
||||
// Enum re-exports
|
||||
export { SubscriptionTier, CourseStatus, GenerationStatus } from '@prisma/client';
|
||||
Reference in New Issue
Block a user