import { INestApplication, Injectable, OnModuleInit } from '@nestjs/common' import { PrismaClient } from '@prisma/client' @Injectable() export class PrismaService extends PrismaClient implements OnModuleInit { constructor() { //SQL 로그를 출력하기위해 추가 super({ log: [ { emit: 'event', level: 'query' }, { emit: 'stdout', level: 'info' }, { emit: 'stdout', level: 'warn' }, { emit: 'stdout', level: 'error' } ], errorFormat: 'colorless' }) } async onModuleInit() { await this.$connect() } async enableShutdownHooks(app: INestApplication) { this.$on('beforeExit', async (event) => { //SQL 로그를 출력하기위해 추가 console.log(event.name) await app.close() }) } }