This commit is contained in:
2024-03-12 16:21:13 +01:00
parent 8a3796e694
commit 2db47b3335
3 changed files with 73 additions and 45 deletions

View File

@@ -3,37 +3,39 @@ import { PrismaClient } from '@prisma/client'
@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit {
// constructor() {
// super({
// log: [
// {
// emit: 'stdout',
// level: 'query',
// },
// {
// emit: 'stdout',
// level: 'error',
// },
// {
// emit: 'stdout',
// level: 'info',
// },
// {
// emit: 'stdout',
// level: 'warn',
// },
// ],
// })
// }
constructor() {
super({
log: [
{
emit: 'stdout',
level: 'query',
},
{
emit: 'stdout',
level: 'error',
},
{
emit: 'stdout',
level: 'info',
},
{
emit: 'stdout',
level: 'warn',
},
],
})
}
async onModuleInit() {
await this.$connect()
}
private exitHandler(app: INestApplication) {
return async () => {
await app.close()
}
}
async enableShutdownHooks(app: INestApplication) {
process.on('exit', this.exitHandler(app))
process.on('beforeExit', this.exitHandler(app))