You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.3 KiB
36 lines
1.3 KiB
import { Module } from '@nestjs/common';
|
|
import { AppController } from './app.controller';
|
|
import { AppService } from './app.service';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
import { join } from 'path';
|
|
import { AuthModule } from './auth/auth.module';
|
|
import { UsersModule } from './users/users.module';
|
|
import { JwtService } from '@nestjs/jwt';
|
|
|
|
@Module({
|
|
imports: [
|
|
ConfigModule.forRoot({ isGlobal: true }), // .env 불러오도록 설정
|
|
TypeOrmModule.forRootAsync({
|
|
imports: [ConfigModule],
|
|
inject: [ConfigService],
|
|
useFactory: (config: ConfigService) => ({
|
|
type: 'mysql',
|
|
host: config.get<string>('DB_HOST'),
|
|
port: parseInt(config.get<string>('DB_PORT', '3306'), 10),
|
|
username: config.get<string>('DB_USERNAME'),
|
|
password: config.get<string>('DB_PASSWORD'),
|
|
database: config.get<string>('DB_DATABASE'),
|
|
entities: [join(__dirname, '**', '*.entity.{ts,js}')],
|
|
synchronize: config.get<string>('NODE_ENV') !== 'production', // 개발 중에만 true
|
|
autoLoadEntities: true,
|
|
logging: true,
|
|
}),
|
|
}),
|
|
AuthModule,
|
|
UsersModule,
|
|
],
|
|
controllers: [AppController],
|
|
providers: [AppService, JwtService],
|
|
})
|
|
export class AppModule {}
|
|
|