Compare commits

...

12 Commits

Author SHA1 Message Date
1a702071c6 1.0.32 2023-07-04 09:13:45 +02:00
0fe2f6a4ae fix(core): update 2023-07-04 09:13:44 +02:00
20d04413c9 1.0.31 2023-07-04 09:13:15 +02:00
e56439e9f4 fix(core): update 2023-07-04 09:13:14 +02:00
c9a9434cd9 1.0.30 2019-11-03 00:51:18 +01:00
5d98dd9089 fix(core): update 2019-11-03 00:51:18 +01:00
2d635fdf7c 1.0.29 2019-11-03 00:49:35 +01:00
1dbf3724d0 fix(core): update 2019-11-03 00:49:35 +01:00
cc7eb8c139 1.0.28 2019-11-03 00:47:19 +01:00
0e01ecbd1a fix(core): update 2019-11-03 00:47:18 +01:00
2d21b40a76 1.0.27 2019-11-02 01:42:04 +01:00
2d1a5cdc50 fix(core): update 2019-11-02 01:42:03 +01:00
21 changed files with 5039 additions and 1449 deletions

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @gitzone/tsdoc
npmci command tsdoc
continue-on-error: true

17
.gitignore vendored
View File

@ -1,5 +1,20 @@
.nogit/ .nogit/
node_modules/
# artifacts
coverage/ coverage/
public/ public/
pages/ pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -1,16 +1,16 @@
# gitzone standard # gitzone ci_default
image: hosttoday/ht-docker-node:npmci image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache: cache:
paths: paths:
- .npmci_cache/ - .npmci_cache/
key: "$CI_BUILD_STAGE" key: '$CI_BUILD_STAGE'
stages: stages:
- security - security
- test - test
- release - release
- metadata - metadata
# ==================== # ====================
# security stage # security stage
@ -18,10 +18,11 @@ stages:
mirror: mirror:
stage: security stage: security
script: script:
- npmci git mirror - npmci git mirror
tags: tags:
- docker - lossless
- notpriv - docker
- notpriv
snyk: snyk:
stage: security stage: security
@ -31,89 +32,89 @@ snyk:
- npmci command npm install --ignore-scripts - npmci command npm install --ignore-scripts
- npmci command snyk test - npmci command snyk test
tags: tags:
- docker - lossless
- notpriv - docker
- notpriv
# ==================== # ====================
# test stage # test stage
# ==================== # ====================
testLTS: testStable:
stage: test stage: test
script: script:
- npmci npm prepare - npmci npm prepare
- npmci node install lts - npmci node install stable
- npmci npm install - npmci npm install
- npmci npm test - npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - lossless
- notpriv - docker
- priv
testSTABLE:
testBuild:
stage: test stage: test
script: script:
- npmci npm prepare - npmci npm prepare
- npmci node install stable - npmci node install stable
- npmci npm install - npmci npm install
- npmci npm test - npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - lossless
- notpriv - docker
- notpriv
release: release:
stage: release stage: release
script: script:
- npmci node install stable - npmci node install stable
- npmci npm publish - npmci npm publish
only: only:
- tags - tags
tags: tags:
- docker - lossless
- notpriv - docker
- notpriv
# ==================== # ====================
# metadata stage # metadata stage
# ==================== # ====================
codequality: codequality:
stage: metadata stage: metadata
image: docker:stable
allow_failure: true allow_failure: true
services:
- docker:stable-dind
script: script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/') - npmci command npm install -g tslint typescript
- docker run - npmci npm prepare
--env SOURCE_CODE="$PWD" - npmci npm install
--volume "$PWD":/code - npmci command "tslint -c tslint.json ./ts/**/*.ts"
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
artifacts:
paths: [codeclimate.json]
tags: tags:
- docker - lossless
- priv - docker
- priv
trigger: trigger:
stage: metadata stage: metadata
script: script:
- npmci trigger - npmci trigger
only: only:
- tags - tags
tags: tags:
- docker - lossless
- notpriv - docker
- notpriv
pages: pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata stage: metadata
script: script:
- npmci command npm install -g typedoc typescript - npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare - npmci npm prepare
- npmci npm install - npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/ - npmci command tsdoc
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
only: only:
@ -121,5 +122,5 @@ pages:
artifacts: artifacts:
expire_in: 1 week expire_in: 1 week
paths: paths:
- public - public
allow_failure: true allow_failure: true

4
.snyk
View File

@ -1,4 +0,0 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.12.0
ignore: {}
patch: {}

11
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

View File

@ -2,5 +2,16 @@
"npmci": { "npmci": {
"npmGlobalTools": [], "npmGlobalTools": [],
"npmAccessLevel": "public" "npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "mojoio",
"gitrepo": "elasticsearch",
"description": "log to elasticsearch in a kibana compatible format",
"npmPackagename": "@mojoio/elasticsearch",
"license": "MIT"
}
} }
} }

1298
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,34 +1,49 @@
{ {
"name": "@mojoio/elasticsearch", "name": "@mojoio/elasticsearch",
"version": "1.0.26", "version": "1.0.32",
"private": false, "private": false,
"description": "log to elasticsearch in a kibana compatible format", "description": "log to elasticsearch in a kibana compatible format",
"main": "dist/index.js", "main": "dist_ts/index.js",
"typings": "dist/index.d.ts", "typings": "dist_ts/index.d.ts",
"author": "Lossless GmbH", "author": "Lossless GmbH",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "(tstest test/)",
"format": "(gitzone format)", "format": "(gitzone format)",
"build": "(tsbuild)" "build": "(tsbuild)",
"buildDocs": "tsdoc"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.0.22", "@gitzone/tsbuild": "^2.1.66",
"@gitzone/tsrun": "^1.1.13", "@gitzone/tsrun": "^1.2.42",
"@gitzone/tstest": "^1.0.15", "@gitzone/tstest": "^1.0.74",
"@pushrocks/qenv": "^2.0.2", "@pushrocks/qenv": "^5.0.2",
"@pushrocks/tapbundle": "^3.0.7", "@pushrocks/tapbundle": "^5.0.8",
"@types/node": "^10.12.2", "@types/node": "^20.3.3"
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/lik": "^3.0.2", "@pushrocks/lik": "^6.0.2",
"@pushrocks/smartdelay": "^2.0.2", "@pushrocks/smartdelay": "^3.0.1",
"@pushrocks/smartlog-interfaces": "^2.0.2", "@pushrocks/smartlog-interfaces": "^3.0.0",
"@pushrocks/smartpromise": "^2.0.5", "@pushrocks/smartpromise": "^4.0.2",
"@pushrocks/smarttime": "^3.0.2", "@pushrocks/smarttime": "^4.0.1",
"@types/elasticsearch": "^5.0.28", "@types/elasticsearch": "^5.0.40",
"elasticsearch": "^15.2.0" "elasticsearch": "^16.7.3"
} },
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"type": "module",
"browserslist": [
"last 1 chrome versions"
]
} }

4609
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
vars: required:
- ELK_DOMAIN - ELK_DOMAIN
- ELK_PORT - ELK_PORT
- ELK_USER - ELK_USER

View File

@ -1,26 +1,26 @@
# elasticlog # @mojoio/elasticsearch
log to elasticsearch in a kibana compatible format log to elasticsearch in a kibana compatible format
## Availabililty ## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@mojoio/elasticsearch)
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/elasticlog) * [gitlab.com (source)](https://gitlab.com/mojoio/elasticsearch)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/elasticlog) * [github.com (source mirror)](https://github.com/mojoio/elasticsearch)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/elasticlog) * [docs (typedoc)](https://mojoio.gitlab.io/elasticsearch/)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/elasticlog/)
## Status for master ## Status for master
[![build status](https://GitLab.com/pushrocks/elasticlog/badges/master/build.svg)](https://GitLab.com/pushrocks/elasticlog/commits/master) Status Category | Status Badge
[![coverage report](https://GitLab.com/pushrocks/elasticlog/badges/master/coverage.svg)](https://GitLab.com/pushrocks/elasticlog/commits/master) -- | --
[![npm downloads per month](https://img.shields.io/npm/dm/elasticlog.svg)](https://www.npmjs.com/package/elasticlog) GitLab Pipelines | [![pipeline status](https://gitlab.com/mojoio/elasticsearch/badges/master/pipeline.svg)](https://lossless.cloud)
[![Dependency Status](https://david-dm.org/pushrocks/elasticlog.svg)](https://david-dm.org/pushrocks/elasticlog) GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/mojoio/elasticsearch/badges/master/coverage.svg)](https://lossless.cloud)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/elasticlog/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/elasticlog/master/dependencies/npm) npm | [![npm downloads per month](https://badgen.net/npm/dy/@mojoio/elasticsearch)](https://lossless.cloud)
[![bitHound Code](https://www.bithound.io/github/pushrocks/elasticlog/badges/code.svg)](https://www.bithound.io/github/pushrocks/elasticlog) Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/mojoio/elasticsearch)](https://lossless.cloud)
[![Known Vulnerabilities](https://snyk.io/test/npm/elasticlog/badge.svg)](https://snyk.io/test/npm/elasticlog) TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/) node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/) Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/) PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@mojoio/elasticsearch)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@mojoio/elasticsearch)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@mojoio/elasticsearch)](https://lossless.cloud)
## Usage ## Usage
@ -32,3 +32,18 @@ For further information read the linked docs at the top of this README.
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html) > | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks) [![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)
## Contribute
We are always happy for code contributions. If you are not the code contributing type that is ok. + Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: [Contribute monthly :)](https://lossless.link/contribute)
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
For further information read the linked docs at the top of this readme.
## Legal
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)

View File

@ -1,6 +1,6 @@
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@pushrocks/tapbundle';
import { Qenv } from '@pushrocks/qenv'; import { Qenv } from '@pushrocks/qenv';
import * as elasticsearch from '../ts/index'; import * as elasticsearch from '../ts/index.js';
const testQenv = new Qenv('./', './.nogit/'); const testQenv = new Qenv('./', './.nogit/');
@ -10,13 +10,11 @@ tap.test('first test', async () => {
testElasticLog = new elasticsearch.ElasticSearch({ testElasticLog = new elasticsearch.ElasticSearch({
indexPrefix: 'smartlog', indexPrefix: 'smartlog',
indexRetention: 7, indexRetention: 7,
domain: process.env.ELK_DOMAIN, domain: testQenv.getEnvVarOnDemand('ELK_DOMAIN'),
port: parseInt(process.env.ELK_PORT, 10), port: parseInt(testQenv.getEnvVarOnDemand('ELK_PORT'), 10),
ssl: true, ssl: true,
user: process.env.ELK_USER,
pass: process.env.ELK_PASS
}); });
expect(testElasticLog).to.be.instanceOf(elasticsearch.ElasticSearch); expect(testElasticLog).toBeInstanceOf(elasticsearch.ElasticSearch);
}); });
tap.test('should send a message to Elasticsearch', async () => { tap.test('should send a message to Elasticsearch', async () => {
@ -30,9 +28,10 @@ tap.test('should send a message to Elasticsearch', async () => {
containerName: 'testcontainer', containerName: 'testcontainer',
environment: 'test', environment: 'test',
runtime: 'node', runtime: 'node',
zone: 'ship.zone' zone: 'ship.zone',
}, },
message: 'hi, this is a testMessage' message: 'GET https://myroute.to.a.cool.destination/sorare?hello=there',
correlation: null,
}); });
}); });

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@mojoio/elasticsearch',
version: '1.0.32',
description: 'log to elasticsearch in a kibana compatible format'
}

View File

@ -21,29 +21,29 @@ export class ElasticIndex {
this.elasticSearchRef.client.cat.indices( this.elasticSearchRef.client.cat.indices(
{ {
format: 'json', format: 'json',
bytes: 'm' bytes: 'm',
}, },
async (err, responseArg: any[]) => { async (err, responseArg: any[]) => {
if(err) { if (err) {
console.log(err); console.log(err);
return; return;
} }
// lets delete indexes that violate the retention // lets delete indexes that violate the retention
if(Array.isArray(responseArg)) { if (Array.isArray(responseArg)) {
const filteredIndices = responseArg.filter(indexObjectArg => { const filteredIndices = responseArg.filter((indexObjectArg) => {
return indexObjectArg.index.startsWith('smartlog'); return indexObjectArg.index.startsWith('smartlog');
}); });
const filteredIndexNames = filteredIndices.map(indexObjectArg => { const filteredIndexNames = filteredIndices.map((indexObjectArg) => {
return indexObjectArg.index; return indexObjectArg.index;
}); });
this.deleteOldIndices(filteredIndexNames); this.deleteOldIndices(filteredIndexNames);
} }
let index = null; let index = null;
if(Array.isArray(responseArg)) { if (Array.isArray(responseArg)) {
index = responseArg.find(indexObject => { index = responseArg.find((indexObject) => {
return indexObject.index === indexArg; return indexObject.index === indexArg;
}); });
} }
@ -52,9 +52,8 @@ export class ElasticIndex {
const done2 = plugins.smartpromise.defer(); const done2 = plugins.smartpromise.defer();
this.elasticSearchRef.client.indices.create( this.elasticSearchRef.client.indices.create(
{ {
waitForActiveShards: '1', waitForActiveShards: '1',
index: indexArg index: indexArg,
}, },
(error, response) => { (error, response) => {
// console.lof(response) // console.lof(response)
@ -70,15 +69,13 @@ export class ElasticIndex {
await done.promise; await done.promise;
} }
public createNewIndex(indexNameArg: string) { public createNewIndex(indexNameArg: string) {}
}
public async deleteOldIndices(indicesArray: string[]) { public async deleteOldIndices(indicesArray: string[]) {
const todayAsUnix: number = Date.now(); const todayAsUnix: number = Date.now();
const rententionPeriodAsUnix: number = plugins.smarttime.units.days( const rententionPeriodAsUnix: number = plugins.smarttime.units.days(
this.elasticSearchRef.indexRetention this.elasticSearchRef.indexRetention
); );
for (const indexName of indicesArray) { for (const indexName of indicesArray) {
const regexResult = /^smartlog-([0-9]*)\.([0-9]*)\.([0-9]*)$/.exec(indexName); const regexResult = /^smartlog-([0-9]*)\.([0-9]*)\.([0-9]*)$/.exec(indexName);
const dateAsUnix: number = new Date( const dateAsUnix: number = new Date(
@ -89,7 +86,7 @@ export class ElasticIndex {
const done2 = plugins.smartpromise.defer(); const done2 = plugins.smartpromise.defer();
this.elasticSearchRef.client.indices.delete( this.elasticSearchRef.client.indices.delete(
{ {
index: indexName index: indexName,
}, },
(err2, response2) => { (err2, response2) => {
if (err2) { if (err2) {

View File

@ -1,4 +1,4 @@
import { ElasticSearch, IStandardLogParams } from './elasticsearch.classes.elasticsearch'; import { ElasticSearch, type IStandardLogParams } from './elasticsearch.classes.elasticsearch.js';
export class ElasticScheduler { export class ElasticScheduler {
elasticSearchRef: ElasticSearch<any>; elasticSearchRef: ElasticSearch<any>;

View File

@ -1,10 +1,10 @@
// interfaces // interfaces
import { Client as ElasticClient } from 'elasticsearch'; import { Client as ElasticClient } from 'elasticsearch';
import { ILogContext, ILogPackage, ILogDestination } from '@pushrocks/smartlog-interfaces'; import type { ILogContext, ILogPackage, ILogDestination } from '@pushrocks/smartlog-interfaces';
// other classes // other classes
import { ElasticScheduler } from './elasticsearch.classes.elasticscheduler'; import { ElasticScheduler } from './elasticsearch.classes.elasticscheduler.js';
import { ElasticIndex } from './elasticsearch.classes.elasticindex'; import { ElasticIndex } from './elasticsearch.classes.elasticindex.js';
export interface IStandardLogParams { export interface IStandardLogParams {
message: string; message: string;
@ -35,7 +35,7 @@ export class ElasticSearch<T> {
*/ */
constructor(optionsArg: IElasticSearchConstructorOptions) { constructor(optionsArg: IElasticSearchConstructorOptions) {
this.client = new ElasticClient({ this.client = new ElasticClient({
host: this.computeHostString(optionsArg) host: this.computeHostString(optionsArg),
// log: 'trace' // log: 'trace'
}); });
this.indexPrefix = optionsArg.indexPrefix; this.indexPrefix = optionsArg.indexPrefix;
@ -56,6 +56,7 @@ export class ElasticSearch<T> {
} else { } else {
hostString = `http://${hostString}`; hostString = `http://${hostString}`;
} }
console.log(hostString);
return hostString; return hostString;
} }
@ -79,8 +80,8 @@ export class ElasticSearch<T> {
type: 'log', type: 'log',
body: { body: {
'@timestamp': new Date(logPackageArg.timestamp).toISOString(), '@timestamp': new Date(logPackageArg.timestamp).toISOString(),
...logPackageArg ...logPackageArg,
} },
}, },
(error, response) => { (error, response) => {
if (error) { if (error) {
@ -96,9 +97,9 @@ export class ElasticSearch<T> {
get logDestination(): ILogDestination { get logDestination(): ILogDestination {
return { return {
handleLog: (smartlogPackageArg: ILogPackage) => { handleLog: async (smartlogPackageArg: ILogPackage) => {
this.log(smartlogPackageArg); this.log(smartlogPackageArg);
} },
}; };
} }
} }

View File

@ -1 +1 @@
export * from './elasticsearch.classes.elasticsearch'; export * from './elasticsearch.classes.elasticsearch.js';

11
tsconfig.json Normal file
View File

@ -0,0 +1,11 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true,
"verbatimModuleSyntax": true,
}
}

View File

@ -1,17 +0,0 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}