Initial
This commit is contained in:
42
listify-api/src/app.module.ts
Normal file
42
listify-api/src/app.module.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ConfigModule, ConfigService } from '@nestjs/config';
|
||||
import { EventEmitterModule } from '@nestjs/event-emitter';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
import { AuthModule } from './auth/auth.module';
|
||||
import { ListTemplatesModule } from './list-templates/list-templates.module';
|
||||
import { ListsModule } from './lists/lists.module';
|
||||
import { MailModule } from './mail/mail.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot({ isGlobal: true }),
|
||||
TypeOrmModule.forRootAsync({
|
||||
inject: [ConfigService],
|
||||
useFactory: (configService: ConfigService) => ({
|
||||
type: 'mysql',
|
||||
host: configService.get<string>('DB_HOST', 'localhost'),
|
||||
port: Number(configService.get<string>('DB_PORT', '3306')),
|
||||
username: configService.get<string>('DB_USERNAME', 'root'),
|
||||
password: configService.get<string>('DB_PASSWORD', ''),
|
||||
database: configService.get<string>('DB_DATABASE', 'listify'),
|
||||
autoLoadEntities: true,
|
||||
synchronize: false,
|
||||
logging: configService.get<string>('DB_LOGGING', 'false') === 'true',
|
||||
}),
|
||||
}),
|
||||
EventEmitterModule.forRoot(),
|
||||
AuthModule,
|
||||
MailModule,
|
||||
ListsModule,
|
||||
ListTemplatesModule,
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule {
|
||||
constructor(configService: ConfigService) {
|
||||
console.log(configService.get<string>('DB_HOST', 'localhost'))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user