added env
test-org/trust-module-backend/pipeline/pr-rc This commit looks good Details

pull/28/head
DmitriyA 2025-06-11 08:14:25 -04:00
parent 4074d45384
commit 57cf65b9a6
3 changed files with 17 additions and 6 deletions

3
.env
View File

@ -24,3 +24,6 @@
# COOKIE_SECURE=false
# COOKIE_SAME_SITE=lax
# Для меню
#RANGES_API_URL=http://192.168.2.39:9999
#RANGES_API_ENDPOINT=/api/ranges/9999

View File

@ -1,17 +1,27 @@
import { Injectable } from '@nestjs/common';
import { HttpService } from '@nestjs/axios';
import { firstValueFrom } from 'rxjs';
import { ConfigService } from '@nestjs/config';
@Injectable()
export class RangeService {
constructor(private readonly httpService: HttpService) { }
private readonly rangesApiUrl: string;
private readonly rangesApiEndpoint: string;
constructor(
private readonly httpService: HttpService,
private readonly configService: ConfigService
) {
this.rangesApiUrl = this.configService.get<string>('RANGES_API_URL', 'localhost:3000');
this.rangesApiEndpoint = this.configService.get<string>('RANGES_API_ENDPOINT', 'localhost:3000');
}
async getRanges(): Promise<Record<string, Array<{ min: number; max: number; status: number }>>> {
try {
const response = await firstValueFrom(
this.httpService.request({
method: 'OPTIONS',
url: 'http://192.168.2.39:9999/api/ranges/9999',
url: `${this.rangesApiUrl}${this.rangesApiEndpoint}`,
headers: {
'Accept': 'application/json'
}
@ -55,7 +65,7 @@ export class RangeService {
async updateRanges(data: Array<{ name: string; ranges: { min: number; max: number; status: number }[] }>) {
try {
const response = await firstValueFrom(
this.httpService.post('http://192.168.2.39:9999/api/ranges/9999', data, {
this.httpService.post(`${this.rangesApiUrl}${this.rangesApiEndpoint}`, data, {
headers: { 'Content-Type': 'application/json' },
})
);
@ -65,6 +75,4 @@ export class RangeService {
throw new Error('Failed to update ranges');
}
}
}

View File

@ -124,7 +124,7 @@ export class PrometheusService {
async fetchMetricsRange(metric: string, start: number, end: number, step: number, filters: Record<string, string> = {}): Promise<PrometheusMetric[]> {
const query = this.buildFilteredQuery(metric, {
...filters,
instance: '192.168.2.34:9050' // Явно фильтруем по нужному instance
instance: '192.168.2.34:9050'
});
try {
const response = await lastValueFrom(