Cleaned up config declaration in constructor
This commit is contained in:
parent
46a0197cd6
commit
a45c16bc42
|
@ -5,7 +5,7 @@ import {
|
||||||
IntegrationBase,
|
IntegrationBase,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
|
|
||||||
const { Client } = require("@elastic/elasticsearch")
|
import { Client, ClientOptions } from "@elastic/elasticsearch"
|
||||||
|
|
||||||
interface ElasticsearchConfig {
|
interface ElasticsearchConfig {
|
||||||
url: string
|
url: string
|
||||||
|
@ -100,22 +100,18 @@ class ElasticSearchIntegration implements IntegrationBase {
|
||||||
constructor(config: ElasticsearchConfig) {
|
constructor(config: ElasticsearchConfig) {
|
||||||
this.config = config
|
this.config = config
|
||||||
|
|
||||||
let newConfig = {
|
const clientConfig: ClientOptions = {
|
||||||
node: this.config.url,
|
node: this.config.url,
|
||||||
ssl: this.config.ssl
|
|
||||||
? {
|
|
||||||
rejectUnauthorized: this.config.rejectUnauthorized,
|
|
||||||
ca: this.config.ca || undefined,
|
|
||||||
}
|
|
||||||
: undefined,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newConfig.ssl && !newConfig.ssl.ca) {
|
if (this.config.ssl) {
|
||||||
delete newConfig.ssl.ca
|
clientConfig.ssl = {
|
||||||
} else if (!newConfig.ssl) {
|
rejectUnauthorized: this.config.rejectUnauthorized,
|
||||||
delete newConfig.ssl
|
ca: this.config.ca || undefined,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.client = new Client(newConfig)
|
|
||||||
|
this.client = new Client(clientConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
async create(query: { index: string; json: object }) {
|
async create(query: { index: string; json: object }) {
|
||||||
|
|
Loading…
Reference in New Issue