Add Env local

main
DenisN 2025-08-08 03:48:54 -04:00
parent 76ce60060f
commit ae9e5d3caa
4 changed files with 24 additions and 15 deletions

View File

@ -8,6 +8,8 @@ import { ConfigModule } from '@nestjs/config';
import { StatusModule } from './status/status.module'; import { StatusModule } from './status/status.module';
import { EventsModule } from './events/events.module'; import { EventsModule } from './events/events.module';
@Module({ @Module({
imports: [ZvksmetricsModule, GruberModule, DatabaseModule, ConfigModule.forRoot({ imports: [ZvksmetricsModule, GruberModule, DatabaseModule, ConfigModule.forRoot({
isGlobal: true, isGlobal: true,
@ -17,3 +19,6 @@ import { EventsModule } from './events/events.module';
providers: [AppService], providers: [AppService],
}) })
export class AppModule {} export class AppModule {}
ConfigModule.forRoot();

View File

@ -6,14 +6,16 @@ import { isInternalThread } from 'node:worker_threads';
export class ClickhouseService { export class ClickhouseService {
async ClickHouseConnect(): Promise<ClickHouse>{ async ClickHouseConnect(): Promise<ClickHouse>{
let connectionData = new ClickHouse({ let connectionData = new ClickHouse({
url: 'http://192.168.2.37', // url: 'http://192.168.2.37',
port: 8123, url: process.env.DATABASE_URL,
port: process.env.DATABASE_PORT,
// port: 8123,
// url: DATABASE_NAME, // url: DATABASE_NAME,
// PORT: DATABASE_PORT, // PORT: DATABASE_PORT,
debug: false, debug: false,
basicAuth: { basicAuth: {
username: 'root', username: process.env.DATABASE_USER,
password: 'dbss', password: process.env.DATABASE_PASSWORD,
}, },
isUseGzip: false, isUseGzip: false,
trimQuery: false, trimQuery: false,

View File

@ -1,5 +1,6 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module'; import { AppModule } from './app.module';
import { ConfigService } from '@nestjs/config';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(AppModule);

View File

@ -1,3 +1,4 @@
import { ConfigModule, ConfigService } from '@nestjs/config';
import { Body, Injectable } from '@nestjs/common'; import { Body, Injectable } from '@nestjs/common';
import axios, { Axios, AxiosResponse } from 'axios'; import axios, { Axios, AxiosResponse } from 'axios';
import { readFile, writeFile } from 'node:fs/promises'; import { readFile, writeFile } from 'node:fs/promises';
@ -313,7 +314,7 @@ export class ZvksmetricsService {
async sendMetrics(inputData: K2Metrics): Promise<string> { async sendMetrics(inputData: K2Metrics): Promise<string> {
let resp: any; 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 body: any = JSON.stringify(inputData);
let options: any = { let options: any = {
headers: { 'Content-Type': 'application/json' } headers: { 'Content-Type': 'application/json' }
@ -347,7 +348,7 @@ export class ZvksmetricsService {
} }
async setMetricsRanges(@Body() rangesData: any = null): Promise<MetricsRanges[]> { async setMetricsRanges(@Body() rangesData: any = null): Promise<MetricsRanges[]> {
let url: string = 'http://192.168.2.39:9999/api/ranges/9999'; let url: any = process.env.METRICS_RANGES;
let options: any = { let options: any = {
headers: { 'Content-Type': 'application/json' } headers: { 'Content-Type': 'application/json' }
}; };
@ -363,7 +364,7 @@ export class ZvksmetricsService {
async saveRanges(inputRanges: string): Promise<any> { async saveRanges(inputRanges: string): Promise<any> {
let ret: any; let ret: any;
let filePath = './src/zvksmetrics/conf/ranges.json'; let filePath: any = process.env. RANGES_CONFIG;
// console.log(inputRanges); // console.log(inputRanges);
let inp: string = JSON.stringify(inputRanges); let inp: string = JSON.stringify(inputRanges);
try { try {
@ -378,7 +379,7 @@ export class ZvksmetricsService {
} }
async setComplexMetrics(@Body() complexData: any = null): Promise<MetricsCalculation[]> { async setComplexMetrics(@Body() complexData: any = null): Promise<MetricsCalculation[]> {
let url: string = 'http://192.168.2.39:9999/api/complex/5555'; let url: any = process.env.COMPLEX_METRICS;
let options: any = { let options: any = {
headers: { 'Content-Type': 'application/json' } headers: { 'Content-Type': 'application/json' }
}; };
@ -392,9 +393,9 @@ export class ZvksmetricsService {
return complexData; return complexData;
} }
async showRangesOptions(filePath: string): Promise<JSON> { async showRangesOptions(filePath: any): Promise<JSON> {
let content: JSON = JSON.parse('{"name":"name"}'); let content: JSON = JSON.parse('{"name":"name"}');
filePath = './src/zvksmetrics/conf/ranges.json'; filePath = process.env.RANGES_CONFIG;
try { try {
content = JSON.parse(await readFile(filePath, { encoding: 'utf8' })); content = JSON.parse(await readFile(filePath, { encoding: 'utf8' }));
} }
@ -406,7 +407,7 @@ export class ZvksmetricsService {
} }
async setIntegrationMetrics(@Body() integrationData: any = null): Promise<MetricsCalculation[]> { async setIntegrationMetrics(@Body() integrationData: any = null): Promise<MetricsCalculation[]> {
let url: string = 'http://192.168.2.39:9999/api/integration/7777'; let url: any = process.env.INTEGRATION_METRICS;
let options: any = { let options: any = {
headers: { 'Content-Type': 'application/json' } headers: { 'Content-Type': 'application/json' }
}; };
@ -420,9 +421,9 @@ export class ZvksmetricsService {
return integrationData; return integrationData;
} }
async showComplexMetricsConfig(filePath: string): Promise<JSON> { async showComplexMetricsConfig(filePath: any): Promise<JSON> {
let content: JSON = JSON.parse('{"name":"name"}'); let content: JSON = JSON.parse('{"name":"name"}');
filePath = './src/zvksmetrics/conf/complex.json'; filePath = process.env.COMPLEX_CONFIG;
try { try {
content = JSON.parse(await readFile(filePath, { encoding: 'utf8' })); content = JSON.parse(await readFile(filePath, { encoding: 'utf8' }));
} }
@ -433,9 +434,9 @@ export class ZvksmetricsService {
return content; return content;
} }
async showIntegrationMetricsConfig(filePath: string): Promise<JSON> { async showIntegrationMetricsConfig(filePath: any): Promise<JSON> {
let content: JSON = JSON.parse('{"name":"name"}'); let content: JSON = JSON.parse('{"name":"name"}');
filePath = './src/zvksmetrics/conf/integration.json'; filePath = process.env.INTEGRATION_CONFIG;
try { try {
content = JSON.parse(await readFile(filePath, { encoding: 'utf8' })); content = JSON.parse(await readFile(filePath, { encoding: 'utf8' }));
} }