mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-22 05:12:20 -06:00
feat(config): add telemetry and metrics configuration options
- Introduce new environment variables for telemetry and Prometheus metrics in .env.example - Create example configuration files for Prometheus and Grafana dashboards - Update main application to utilize new configuration settings for Sentry, audio converter, and proxy - Enhance channel services to support audio conversion API integration - Implement middleware for metrics IP whitelisting and basic authentication in routes
This commit is contained in:
@@ -13,7 +13,7 @@ import { chatbotController } from '@api/server.module';
|
||||
import { CacheService } from '@api/services/cache.service';
|
||||
import { ChannelStartupService } from '@api/services/channel.service';
|
||||
import { Events, wa } from '@api/types/wa.types';
|
||||
import { Chatwoot, ConfigService, Openai, S3 } from '@config/env.config';
|
||||
import { AudioConverter, Chatwoot, ConfigService, Openai, S3 } from '@config/env.config';
|
||||
import { BadRequestException, InternalServerErrorException } from '@exceptions';
|
||||
import { createJid } from '@utils/createJid';
|
||||
import axios from 'axios';
|
||||
@@ -622,7 +622,8 @@ export class EvolutionStartupService extends ChannelStartupService {
|
||||
number = number.replace(/\D/g, '');
|
||||
const hash = `${number}-${new Date().getTime()}`;
|
||||
|
||||
if (process.env.API_AUDIO_CONVERTER) {
|
||||
const audioConverterConfig = this.configService.get<AudioConverter>('AUDIO_CONVERTER');
|
||||
if (audioConverterConfig.API_URL) {
|
||||
try {
|
||||
this.logger.verbose('Using audio converter API');
|
||||
const formData = new FormData();
|
||||
@@ -640,10 +641,10 @@ export class EvolutionStartupService extends ChannelStartupService {
|
||||
|
||||
formData.append('format', 'mp4');
|
||||
|
||||
const response = await axios.post(process.env.API_AUDIO_CONVERTER, formData, {
|
||||
const response = await axios.post(audioConverterConfig.API_URL, formData, {
|
||||
headers: {
|
||||
...formData.getHeaders(),
|
||||
apikey: process.env.API_AUDIO_CONVERTER_KEY,
|
||||
apikey: audioConverterConfig.API_KEY,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import { chatbotController } from '@api/server.module';
|
||||
import { CacheService } from '@api/services/cache.service';
|
||||
import { ChannelStartupService } from '@api/services/channel.service';
|
||||
import { Events, wa } from '@api/types/wa.types';
|
||||
import { Chatwoot, ConfigService, Database, Openai, S3, WaBusiness } from '@config/env.config';
|
||||
import { AudioConverter, Chatwoot, ConfigService, Database, Openai, S3, WaBusiness } from '@config/env.config';
|
||||
import { BadRequestException, InternalServerErrorException } from '@exceptions';
|
||||
import { createJid } from '@utils/createJid';
|
||||
import { status } from '@utils/renderStatus';
|
||||
@@ -1300,7 +1300,8 @@ export class BusinessStartupService extends ChannelStartupService {
|
||||
number = number.replace(/\D/g, '');
|
||||
const hash = `${number}-${new Date().getTime()}`;
|
||||
|
||||
if (process.env.API_AUDIO_CONVERTER) {
|
||||
const audioConverterConfig = this.configService.get<AudioConverter>('AUDIO_CONVERTER');
|
||||
if (audioConverterConfig.API_URL) {
|
||||
this.logger.verbose('Using audio converter API');
|
||||
const formData = new FormData();
|
||||
|
||||
@@ -1317,10 +1318,10 @@ export class BusinessStartupService extends ChannelStartupService {
|
||||
|
||||
formData.append('format', 'mp3');
|
||||
|
||||
const response = await axios.post(process.env.API_AUDIO_CONVERTER, formData, {
|
||||
const response = await axios.post(audioConverterConfig.API_URL, formData, {
|
||||
headers: {
|
||||
...formData.getHeaders(),
|
||||
apikey: process.env.API_AUDIO_CONVERTER_KEY,
|
||||
apikey: audioConverterConfig.API_KEY,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ import { ChannelStartupService } from '@api/services/channel.service';
|
||||
import { Events, MessageSubtype, TypeMediaMessage, wa } from '@api/types/wa.types';
|
||||
import { CacheEngine } from '@cache/cacheengine';
|
||||
import {
|
||||
AudioConverter,
|
||||
CacheConf,
|
||||
Chatwoot,
|
||||
ConfigService,
|
||||
@@ -2837,7 +2838,8 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
}
|
||||
|
||||
public async processAudio(audio: string): Promise<Buffer> {
|
||||
if (process.env.API_AUDIO_CONVERTER) {
|
||||
const audioConverterConfig = this.configService.get<AudioConverter>('AUDIO_CONVERTER');
|
||||
if (audioConverterConfig.API_URL) {
|
||||
this.logger.verbose('Using audio converter API');
|
||||
const formData = new FormData();
|
||||
|
||||
@@ -2847,8 +2849,8 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
formData.append('base64', audio);
|
||||
}
|
||||
|
||||
const { data } = await axios.post(process.env.API_AUDIO_CONVERTER, formData, {
|
||||
headers: { ...formData.getHeaders(), apikey: process.env.API_AUDIO_CONVERTER_KEY },
|
||||
const { data } = await axios.post(audioConverterConfig.API_URL, formData, {
|
||||
headers: { ...formData.getHeaders(), apikey: audioConverterConfig.API_KEY },
|
||||
});
|
||||
|
||||
if (!data.audio) {
|
||||
|
||||
@@ -31,7 +31,9 @@ export class WebsocketController extends EventController implements EventControl
|
||||
const params = new URLSearchParams(url.search);
|
||||
|
||||
const { remoteAddress } = req.socket;
|
||||
const isAllowedHost = (process.env.WEBSOCKET_ALLOWED_HOSTS || '127.0.0.1,::1,::ffff:127.0.0.1')
|
||||
const websocketConfig = configService.get<Websocket>('WEBSOCKET');
|
||||
const allowedHosts = websocketConfig.ALLOWED_HOSTS || '127.0.0.1,::1,::ffff:127.0.0.1';
|
||||
const isAllowedHost = allowedHosts
|
||||
.split(',')
|
||||
.map((h) => h.trim())
|
||||
.includes(remoteAddress);
|
||||
|
||||
@@ -26,7 +26,7 @@ const minioClient = (() => {
|
||||
}
|
||||
})();
|
||||
|
||||
const bucketName = process.env.S3_BUCKET;
|
||||
const bucketName = BUCKET.BUCKET_NAME;
|
||||
|
||||
const bucketExists = async () => {
|
||||
if (minioClient) {
|
||||
|
||||
Reference in New Issue
Block a user