Skip to content

Commit

Permalink
feat: 불필요한 주석 제거, 환경변수에 따라 typeORM세팅 달라지게 하기
Browse files Browse the repository at this point in the history
  • Loading branch information
begong313 committed Nov 6, 2024
1 parent 9c9ff3f commit c3e37cf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions apps/api/config/typeorm.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// config/typeorm.config.ts
import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { TypeOrmModuleOptions, TypeOrmOptionsFactory } from '@nestjs/typeorm';
Expand All @@ -8,6 +7,7 @@ export class TypeOrmConfigService implements TypeOrmOptionsFactory {
constructor(private configService: ConfigService) {}

createTypeOrmOptions(): TypeOrmModuleOptions {
const nodeEnv = this.configService.get<string>('NODE_ENV', 'development');
return {
type: 'mysql',
host: this.configService.get<string>('DATABASE_HOST'),
Expand All @@ -16,7 +16,8 @@ export class TypeOrmConfigService implements TypeOrmOptionsFactory {
password: this.configService.get<string>('DATABASE_PASSWORD'),
database: this.configService.get<string>('DATABASE_NAME'),
entities: [__dirname + '/../**/*.entity{.ts,.js}'],
synchronize: true, // 개발 환경에서만 사용 (프로덕션에선 비활성화 권장)
synchronize: nodeEnv !== 'production',
logging: nodeEnv !== 'production',
};
}
}
2 changes: 1 addition & 1 deletion apps/api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { UserModule } from './user/user.module';
UserModule,
TypeOrmModule.forRootAsync({
imports: [ConfigModule],
useClass: TypeOrmConfigService, // TypeOrmConfigService로 대체
useClass: TypeOrmConfigService,
}),
],
controllers: [AppController],
Expand Down

0 comments on commit c3e37cf

Please sign in to comment.