What is the proper way to use the ElasticsearchModule globally?
I am currently getting the error:
Cannot read properties of undefined (reading 'cloud')
My Code:
import { Global, Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { ElasticsearchModule } from '@nestjs/elasticsearch';
import { ElasticsearchService } from '@nestjs/elasticsearch';
@Global()
@Module({
imports: [
ConfigModule,
ElasticsearchModule.registerAsync({
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({
node: configService.get('ELASTICSEARCH_URL'),
auth: {
username: configService.get('ELASTICSEARCH_USERNAME') ?? '',
password: configService.get('ELASTICSEARCH_PASSWORD') ?? '',
},
}),
inject: [ConfigService],
}),
],
providers: [ElasticsearchService],
exports: [ElasticSearchModule, ElasticsearchService],
})
export class ElasticSearchModule {}