Compare commits

...

4 Commits

Author SHA1 Message Date
2a595a1a9a 1.0.44 2023-07-05 23:45:48 +02:00
d62b18e93c fix(core): update 2023-07-05 23:45:48 +02:00
d6176f820a 1.0.43 2023-07-05 17:27:24 +02:00
0ebc1d5288 fix(core): update 2023-07-05 17:27:24 +02:00
5 changed files with 13 additions and 13 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@apiclient.xyz/elasticsearch",
"version": "1.0.42",
"version": "1.0.44",
"private": false,
"description": "log to elasticsearch in a kibana compatible format",
"main": "dist_ts/index.js",

View File

@ -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);
});

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@apiclient.xyz/elasticsearch',
version: '1.0.42',
version: '1.0.44',
description: 'log to elasticsearch in a kibana compatible format'
}

View File

@ -14,7 +14,7 @@ export class ElasticIndex {
public async ensureIndex(prefixArg: string, indexNameArg: string) {
if (this.stringmap.checkString(indexNameArg)) {
return;
return indexNameArg;
}
const responseArg = await this.elasticSearchRef.client.cat.indices({
format: 'json',

View File

@ -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<T> {
@ -34,10 +36,7 @@ export class ElasticSearch<T> {
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;
@ -52,8 +51,7 @@ export class ElasticSearch<T> {
return;
}
const response = await this.elasticIndex.ensureIndex(this.indexPrefix, indexToUse);
console.log(response);
const resultIndexName = await this.elasticIndex.ensureIndex(this.indexPrefix, indexToUse);
this.client.index(
{
index: indexToUse,