From c3e37cf1f54de12a118cd5f941a707979a292dbf Mon Sep 17 00:00:00 2001 From: JongBin Noh <95959567+begong313@users.noreply.github.com> Date: Wed, 6 Nov 2024 18:44:50 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C=20?= =?UTF-8?q?=EC=A3=BC=EC=84=9D=20=EC=A0=9C=EA=B1=B0,=20=ED=99=98=EA=B2=BD?= =?UTF-8?q?=EB=B3=80=EC=88=98=EC=97=90=20=EB=94=B0=EB=9D=BC=20typeORM?= =?UTF-8?q?=EC=84=B8=ED=8C=85=20=EB=8B=AC=EB=9D=BC=EC=A7=80=EA=B2=8C=20?= =?UTF-8?q?=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/api/config/typeorm.config.ts | 5 +++-- apps/api/src/app.module.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/api/config/typeorm.config.ts b/apps/api/config/typeorm.config.ts index e12325c1..860b79f1 100644 --- a/apps/api/config/typeorm.config.ts +++ b/apps/api/config/typeorm.config.ts @@ -1,4 +1,3 @@ -// config/typeorm.config.ts import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { TypeOrmModuleOptions, TypeOrmOptionsFactory } from '@nestjs/typeorm'; @@ -8,6 +7,7 @@ export class TypeOrmConfigService implements TypeOrmOptionsFactory { constructor(private configService: ConfigService) {} createTypeOrmOptions(): TypeOrmModuleOptions { + const nodeEnv = this.configService.get('NODE_ENV', 'development'); return { type: 'mysql', host: this.configService.get('DATABASE_HOST'), @@ -16,7 +16,8 @@ export class TypeOrmConfigService implements TypeOrmOptionsFactory { password: this.configService.get('DATABASE_PASSWORD'), database: this.configService.get('DATABASE_NAME'), entities: [__dirname + '/../**/*.entity{.ts,.js}'], - synchronize: true, // 개발 환경에서만 사용 (프로덕션에선 비활성화 권장) + synchronize: nodeEnv !== 'production', + logging: nodeEnv !== 'production', }; } } diff --git a/apps/api/src/app.module.ts b/apps/api/src/app.module.ts index 4ae337e6..ce2c5475 100644 --- a/apps/api/src/app.module.ts +++ b/apps/api/src/app.module.ts @@ -23,7 +23,7 @@ import { UserModule } from './user/user.module'; UserModule, TypeOrmModule.forRootAsync({ imports: [ConfigModule], - useClass: TypeOrmConfigService, // TypeOrmConfigService로 대체 + useClass: TypeOrmConfigService, }), ], controllers: [AppController],