From 0ebc1d52883e264b3ca4d3bb99086f0b9d3682a9 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Wed, 5 Jul 2023 17:27:24 +0200 Subject: [PATCH] fix(core): update --- test/test.nonci.ts | 6 ++++-- ts/00_commitinfo_data.ts | 2 +- ts/elasticsearch.classes.elasticsearch.ts | 11 +++++------ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/test/test.nonci.ts b/test/test.nonci.ts index e73becc..6d3eff7 100644 --- a/test/test.nonci.ts +++ b/test/test.nonci.ts @@ -9,8 +9,10 @@ tap.test('first test', async () => { indexPrefix: 'testprefix', indexRetention: 7, node: 'http://localhost:9200', - user: 'elastic', - pass: 'YourPassword' + auth: { + username: 'elastic', + password: 'YourPassword' + } }); expect(testElasticLog).toBeInstanceOf(elasticsearch.ElasticSearch); }); diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index dfb498c..e454493 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@apiclient.xyz/elasticsearch', - version: '1.0.42', + version: '1.0.43', description: 'log to elasticsearch in a kibana compatible format' } diff --git a/ts/elasticsearch.classes.elasticsearch.ts b/ts/elasticsearch.classes.elasticsearch.ts index cc03d03..8976846 100644 --- a/ts/elasticsearch.classes.elasticsearch.ts +++ b/ts/elasticsearch.classes.elasticsearch.ts @@ -15,8 +15,10 @@ export interface IElasticSearchConstructorOptions { indexPrefix: string; indexRetention: number; node: string; - user?: string; - pass?: string; + auth?: { + username: string; + password: string; + }; } export class ElasticSearch { @@ -34,10 +36,7 @@ export class ElasticSearch { constructor(optionsArg: IElasticSearchConstructorOptions) { this.client = new ElasticClient({ node: optionsArg.node, - auth: { - username: optionsArg.user, - password: optionsArg.pass, - } + ...(optionsArg.auth && { auth: optionsArg.auth }), }); this.indexPrefix = optionsArg.indexPrefix; this.indexRetention = optionsArg.indexRetention;