Skip to content

Commit

Permalink
Use forrootAsync for MongooseModule
Browse files Browse the repository at this point in the history
  • Loading branch information
thetkpark committed Jun 7, 2021
1 parent 88b3515 commit da9520b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Module } from '@nestjs/common'
import { ConfigModule } from '@nestjs/config'
import { ConfigModule, ConfigService } from '@nestjs/config'
import { AppController } from './app.controller'
import { AppService } from './app.service'
import { UserModule } from './user/user.module'
Expand All @@ -15,9 +15,13 @@ import { APP_GUARD } from '@nestjs/core'
isGlobal: true,
envFilePath: '.env',
}),
MongooseModule.forRoot(process.env.MONGODB_CONNECTION_URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
MongooseModule.forRootAsync({
inject: [ConfigService],
useFactory: async (configService: ConfigService) => ({
uri: configService.get<string>('MONGODB_CONNECTION_URL'),
useNewUrlParser: true,
useUnifiedTopology: true,
}),
}),
ThrottlerModule.forRoot({
ttl: 5,
Expand Down

0 comments on commit da9520b

Please sign in to comment.