Skip to content

Instantly share code, notes, and snippets.

@kop7
Created August 12, 2020 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kop7/2acfa52075222647d684a5972a40f5ea to your computer and use it in GitHub Desktop.
Save kop7/2acfa52075222647d684a5972a40f5ea to your computer and use it in GitHub Desktop.
Search Module
import { Module, OnModuleInit } from '@nestjs/common';
import { SearchService } from './search.service';
import { ElasticsearchModule } from '@nestjs/elasticsearch';
import { ConfigModule } from '../../config/config.module';
import { ConfigService } from '../../config/config.service';
@Module({
imports: [
ElasticsearchModule.registerAsync({
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({
node: configService.get('ELASTICSEARCH_NODE'),
maxRetries: 10,
requestTimeout: 60000,
pingTimeout: 60000,
sniffOnStart: true,
}),
inject: [ConfigService],
}),
ConfigModule,
],
providers: [SearchService],
exports: [SearchService],
})
export class SearchModule implements OnModuleInit {
constructor(private searchService: SearchService) {}
onModuleInit() {
this.searchService.createIndex().then();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment