Skip to content

Instantly share code, notes, and snippets.

@OttlikG
Created March 18, 2023 13:40
Show Gist options
  • Save OttlikG/3f68fcc8ef5357200ffdbaf5f6d46a95 to your computer and use it in GitHub Desktop.
Save OttlikG/3f68fcc8ef5357200ffdbaf5f6d46a95 to your computer and use it in GitHub Desktop.
@nestjs/elasticsearch issue
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ElasticsearchModule } from '@nestjs/elasticsearch';
import * as fs from 'fs';
console.log('-- cert', fs.readFileSync('../http_ca.crt'));
@Module({
imports: [
ElasticsearchModule.register({
node: 'http://localhost:9200',
auth: {
username: 'elastic',
password: 'the-password',
},
tls: {
ca: fs.readFileSync('../http_ca.crt'),
rejectUnauthorized: false,
},
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
import { Injectable } from '@nestjs/common';
import { ElasticsearchService } from '@nestjs/elasticsearch';
@Injectable()
export class AppService {
constructor(private readonly elasticsearchService: ElasticsearchService) {}
async getHello(): Promise<any> {
const result = await this.elasticsearchService.search();
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment