• Home
  • About
    • lahuman photo

      lahuman

      열심히 사는 아저씨

    • Learn More
    • Facebook
    • LinkedIn
    • Github
  • Posts
    • All Posts
    • All Tags
  • Projects

nestjs에서 registerAsync 사용시 isGlobal 설정

18 Apr 2023

Reading time ~1 minute

nestjs에서 registerAsync 사용시 isGlobal 설정

useFactory에 isGlobal을 설정 했지만, 동작 하지 않아서 테스트 해보다 보니 위치가 아래와 같습니다.

@Module({
  imports: [
    ConfigModule.forRoot({
      envFilePath: ['.env.local', '.env'],
      isGlobal: true,
      load: [database, logging, redis, cache, throttler],
    }),
    CacheModule.registerAsync({
      isGlobal: true,  // 여기에 들어가야 한다.
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (configService: ConfigService) =>
        configService.get('cacheConfig'), // 여기에 넣었다가 실패..
    }),
  ],
  controllers: [AppController],
  providers: [ ],
})
export class AppModule implements NestModule {

}

별것도 아닌데 하루 종일 삽질 했네요.



nestjsregisterAsyncisGlobal Share Tweet +1