codemask-labs / nestjs-elasticsearch

MIT License
5 stars 1 forks source link

How can this be used with a username/password in the env file? #202

Open jnovak-SM2Dev opened 2 weeks ago

jnovak-SM2Dev commented 2 weeks ago

How can this be used with a username/password in the env file? In the @nestjs/elasticsearch module you would use registerAsync and use the configService like below. Is there a way to do the same thing with this package without having the auth info in the repo?

ElasticsearchModule.registerAsync({
      imports: [ConfigModule],
      useFactory: async (configService: ConfigService) => ({
        node: configService.get('ELASTICSEARCH_NODE'),
        auth: {
          username: configService.get('ELASTICSEARCH_USERNAME') ?? '',
          password: configService.get('ELASTICSEARCH_PASSWORD') ?? '',
        },
      }),
      inject: [ConfigService],
    }),
przemyslawwalczak commented 1 week ago

What do you mean by auth info in the repo?

We don't store .env on production environment like Kubernetes or Docker. Not sure how your application reads these environment variables but they are usually available through process.env (and coming from secrets) so they are safely stored 🤔 .

przemyslawwalczak commented 1 week ago

Unless, you are asking about registerAsync not available in the module?

jnovak-SM2Dev commented 1 week ago

I'm wondering how you pull in the env variables without access to registerAsync or configService.

przemyslawwalczak commented 1 week ago

yeah you are right 👍 - we should add registerAsync here 🤔 cc @ada-krupa @adrianboratyn