diff --git a/src/app.module.ts b/src/app.module.ts index 0df6db5..29666ea 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -8,6 +8,8 @@ import { ConfigModule } from '@nestjs/config'; import { StatusModule } from './status/status.module'; import { EventsModule } from './events/events.module'; + + @Module({ imports: [ZvksmetricsModule, GruberModule, DatabaseModule, ConfigModule.forRoot({ isGlobal: true, @@ -17,3 +19,6 @@ import { EventsModule } from './events/events.module'; providers: [AppService], }) export class AppModule {} + + ConfigModule.forRoot(); + diff --git a/src/database/clickhouse/clickhouse.service.ts b/src/database/clickhouse/clickhouse.service.ts index 79f16fd..04a91ad 100644 --- a/src/database/clickhouse/clickhouse.service.ts +++ b/src/database/clickhouse/clickhouse.service.ts @@ -6,14 +6,16 @@ import { isInternalThread } from 'node:worker_threads'; export class ClickhouseService { async ClickHouseConnect(): Promise{ let connectionData = new ClickHouse({ - url: 'http://192.168.2.37', - port: 8123, + // url: 'http://192.168.2.37', + url: process.env.DATABASE_URL, + port: process.env.DATABASE_PORT, + // port: 8123, // url: DATABASE_NAME, // PORT: DATABASE_PORT, debug: false, basicAuth: { - username: 'root', - password: 'dbss', + username: process.env.DATABASE_USER, + password: process.env.DATABASE_PASSWORD, }, isUseGzip: false, trimQuery: false, diff --git a/src/main.ts b/src/main.ts index 368884c..17c86c8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,6 @@ import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; +import { ConfigService } from '@nestjs/config'; async function bootstrap() { const app = await NestFactory.create(AppModule); diff --git a/src/zvksmetrics/zvksmetrics.service.ts b/src/zvksmetrics/zvksmetrics.service.ts index 7646c6f..e979d6f 100644 --- a/src/zvksmetrics/zvksmetrics.service.ts +++ b/src/zvksmetrics/zvksmetrics.service.ts @@ -1,3 +1,4 @@ +import { ConfigModule, ConfigService } from '@nestjs/config'; import { Body, Injectable } from '@nestjs/common'; import axios, { Axios, AxiosResponse } from 'axios'; import { readFile, writeFile } from 'node:fs/promises'; @@ -313,7 +314,7 @@ export class ZvksmetricsService { async sendMetrics(inputData: K2Metrics): Promise { let resp: any; - let path: string = 'http://192.168.2.34:9050/update'; + let path: any = process.env.IM_UPDATE; let body: any = JSON.stringify(inputData); let options: any = { headers: { 'Content-Type': 'application/json' } @@ -347,7 +348,7 @@ export class ZvksmetricsService { } async setMetricsRanges(@Body() rangesData: any = null): Promise { - let url: string = 'http://192.168.2.39:9999/api/ranges/9999'; + let url: any = process.env.METRICS_RANGES; let options: any = { headers: { 'Content-Type': 'application/json' } }; @@ -363,7 +364,7 @@ export class ZvksmetricsService { async saveRanges(inputRanges: string): Promise { let ret: any; - let filePath = './src/zvksmetrics/conf/ranges.json'; + let filePath: any = process.env. RANGES_CONFIG; // console.log(inputRanges); let inp: string = JSON.stringify(inputRanges); try { @@ -378,7 +379,7 @@ export class ZvksmetricsService { } async setComplexMetrics(@Body() complexData: any = null): Promise { - let url: string = 'http://192.168.2.39:9999/api/complex/5555'; + let url: any = process.env.COMPLEX_METRICS; let options: any = { headers: { 'Content-Type': 'application/json' } }; @@ -392,9 +393,9 @@ export class ZvksmetricsService { return complexData; } - async showRangesOptions(filePath: string): Promise { + async showRangesOptions(filePath: any): Promise { let content: JSON = JSON.parse('{"name":"name"}'); - filePath = './src/zvksmetrics/conf/ranges.json'; + filePath = process.env.RANGES_CONFIG; try { content = JSON.parse(await readFile(filePath, { encoding: 'utf8' })); } @@ -406,7 +407,7 @@ export class ZvksmetricsService { } async setIntegrationMetrics(@Body() integrationData: any = null): Promise { - let url: string = 'http://192.168.2.39:9999/api/integration/7777'; + let url: any = process.env.INTEGRATION_METRICS; let options: any = { headers: { 'Content-Type': 'application/json' } }; @@ -420,9 +421,9 @@ export class ZvksmetricsService { return integrationData; } - async showComplexMetricsConfig(filePath: string): Promise { + async showComplexMetricsConfig(filePath: any): Promise { let content: JSON = JSON.parse('{"name":"name"}'); - filePath = './src/zvksmetrics/conf/complex.json'; + filePath = process.env.COMPLEX_CONFIG; try { content = JSON.parse(await readFile(filePath, { encoding: 'utf8' })); } @@ -433,9 +434,9 @@ export class ZvksmetricsService { return content; } - async showIntegrationMetricsConfig(filePath: string): Promise { + async showIntegrationMetricsConfig(filePath: any): Promise { let content: JSON = JSON.parse('{"name":"name"}'); - filePath = './src/zvksmetrics/conf/integration.json'; + filePath = process.env.INTEGRATION_CONFIG; try { content = JSON.parse(await readFile(filePath, { encoding: 'utf8' })); }