30 lines
856 B
TypeScript
30 lines
856 B
TypeScript
import { Module } from '@nestjs/common';
|
|
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
import { MongooseModule } from '@nestjs/mongoose';
|
|
import { AppController } from './app.controller';
|
|
import { AppService } from './app.service';
|
|
import Configuration from './config/configuration';
|
|
|
|
@Module({
|
|
imports: [
|
|
ConfigModule.forRoot({
|
|
load: [Configuration],
|
|
isGlobal: true,
|
|
}),
|
|
MongooseModule.forRootAsync({
|
|
imports: [ConfigModule],
|
|
inject: [ConfigService],
|
|
useFactory: async (config: ConfigService) => ({
|
|
uri: `mongodb://${config.get<string>(
|
|
'database.host',
|
|
)}:${config.get<number>('database.port')}/${config.get<string>(
|
|
'database.name',
|
|
)}`,
|
|
}),
|
|
}),
|
|
],
|
|
controllers: [AppController],
|
|
providers: [AppService],
|
|
})
|
|
export class AppModule {}
|