Closed matte0080 closed 3 years ago
env.development
LOGGER_SERVICE_URL=localhost:30043 ELASTICSEARCH_HOST=http://localhost:9200
app.module
import { MiddlewareConsumer, Module, NestModule, RequestMethod } from '@nestjs/common'; import { ConfigModule, ConfigService } from '@nestjs/config'; import * as cors from 'cors'; import * as helmet from 'helmet'; import { ActionsModule } from './actions/actions.module'; import { AppController } from './app.controller'; import { AppService } from './app.service'; import { logger } from './logger.middleware'; @Module({ imports: [ ConfigModule.forRoot({ isGlobal: true, envFilePath: '.env.development', }), ActionsModule, ], controllers: [AppController], providers: [AppService], }) export class AppModule implements NestModule { configure(consumer: MiddlewareConsumer) { consumer .apply(cors(), helmet(), logger) .forRoutes({ path: 'actions', method: RequestMethod.ALL }); } }
action.module
ClientsModule.registerAsync([ { imports: [ConfigModule], name: 'LOGGER_PACKAGE', useFactory: (configService: ConfigService) => { console.log(configService.get('LOGGER_SERVICE_URL')); console.log(configService.get('ELASTICSEARCH_HOST')); return { transport: Transport.GRPC, options: { url: configService.get('LOGGER_SERVICE_URL'), package: 'logger', protoPath: join(__dirname, '../proto/logger.proto'), }, }; }, inject: [ConfigService], }, ]), ConfigModule, ] ``` `The issue is: configService.get('LOGGER_SERVICE_URL') is always **undefined**. Why!? `
Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.
env.development
app.module
action.module