mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-13 16:22:59 +10:00
refactor(v4.0.0-alpha): beginning of a new era
This commit is contained in:
36
apps/server/src/database/database.module.ts
Normal file
36
apps/server/src/database/database.module.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import { Logger, Module } from "@nestjs/common";
|
||||
import { ConfigService } from "@nestjs/config";
|
||||
import {
|
||||
loggingMiddleware,
|
||||
PrismaModule,
|
||||
PrismaService,
|
||||
providePrismaClientExceptionFilter,
|
||||
} from "nestjs-prisma";
|
||||
|
||||
import { Config } from "@/server/config/schema";
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
PrismaModule.forRootAsync({
|
||||
isGlobal: true,
|
||||
inject: [ConfigService],
|
||||
useFactory: async (configService: ConfigService<Config>) => ({
|
||||
prismaOptions: { datasourceUrl: configService.get("DATABASE_URL") },
|
||||
middlewares: [
|
||||
...(configService.get("NODE_ENV") === "development"
|
||||
? [
|
||||
loggingMiddleware({
|
||||
logLevel: "debug",
|
||||
logger: new Logger(PrismaService.name),
|
||||
logMessage: (query) =>
|
||||
`[Query] ${query.model}.${query.action} - ${query.executionTime}ms`,
|
||||
}),
|
||||
]
|
||||
: []),
|
||||
],
|
||||
}),
|
||||
}),
|
||||
],
|
||||
providers: [providePrismaClientExceptionFilter()],
|
||||
})
|
||||
export class DatabaseModule {}
|
||||
Reference in New Issue
Block a user