$ npm i --save @nestjs/elasticsearch elasticsearch @types/elasticsearch
Quite often you might want to asynchronously pass your module options instead of passing them beforehand. In such case, use
registerAsync() method, that provides a couple of various ways to deal with async data.
1. Use factory
Obviously, our factory behaves like every other one (might be
async and is able to inject dependencies through
2. Use class
Above construction will instantiate
ElasticsearchModule and will leverage it to create options object.
3. Use existing
It works the same as
useClass with one critical difference -
ElasticsearchModule will lookup imported modules to reuse already created
ConfigService, instead of instantiating it on its own.
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
Stay in touch
Nest is MIT licensed.