backend base
This commit is contained in:
34
backend/src/app.module.ts
Executable file
34
backend/src/app.module.ts
Executable file
@@ -0,0 +1,34 @@
|
||||
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: async (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 {}
|
Reference in New Issue
Block a user