Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to access config in the main file of a microservice? #5102

Closed
wayou opened this issue Jul 16, 2020 · 1 comment
Closed

How to access config in the main file of a microservice? #5102

wayou opened this issue Jul 16, 2020 · 1 comment
Labels
needs triage This issue has not been looked into type: question 🙌

Comments

@wayou
Copy link
Contributor

wayou commented Jul 16, 2020

According to the doc, we can access config in main file by:

const configService = app.get(ConfigService);

while this may be not possible for microservice.

async function bootstrap() {
  // how to access config via app before app was created ❓
  // const PORT = app.get(ConfigService).get('PORT');
  const PORT = 4000;
  const app = await NestFactory.createMicroservice<MicroserviceOptions>(
    AppModule,
    {
      transport: Transport.TCP,
      options: {
        port: PORT,
      },
    },
  );
  await app.listen(() => Logger.log(`microservice started on ${PORT}`));
}
@wayou wayou added needs triage This issue has not been looked into type: question 🙌 labels Jul 16, 2020
@kamilmysliwiec
Copy link
Member

Duplicate of #2343

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been looked into type: question 🙌
Projects
None yet
Development

No branches or pull requests

2 participants