Created
August 12, 2020 18:50
-
-
Save kop7/2acfa52075222647d684a5972a40f5ea to your computer and use it in GitHub Desktop.
Search Module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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