mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-24 06:07:45 -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:
@@ -1,5 +1,6 @@
|
||||
import { prismaRepository } from '@api/server.module';
|
||||
import { CacheService } from '@api/services/cache.service';
|
||||
import { CacheConf, configService } from '@config/env.config';
|
||||
import { INSTANCE_DIR } from '@config/path.config';
|
||||
import { AuthenticationState, BufferJSON, initAuthCreds, WAProto as proto } from 'baileys';
|
||||
import fs from 'fs/promises';
|
||||
@@ -85,9 +86,10 @@ export default async function useMultiFileAuthStatePrisma(
|
||||
|
||||
async function writeData(data: any, key: string): Promise<any> {
|
||||
const dataString = JSON.stringify(data, BufferJSON.replacer);
|
||||
const cacheConfig = configService.get<CacheConf>('CACHE');
|
||||
|
||||
if (key != 'creds') {
|
||||
if (process.env.CACHE_REDIS_ENABLED === 'true') {
|
||||
if (cacheConfig.REDIS.ENABLED) {
|
||||
return await cache.hSet(sessionId, key, data);
|
||||
} else {
|
||||
await fs.writeFile(localFile(key), dataString);
|
||||
@@ -101,9 +103,10 @@ export default async function useMultiFileAuthStatePrisma(
|
||||
async function readData(key: string): Promise<any> {
|
||||
try {
|
||||
let rawData;
|
||||
const cacheConfig = configService.get<CacheConf>('CACHE');
|
||||
|
||||
if (key != 'creds') {
|
||||
if (process.env.CACHE_REDIS_ENABLED === 'true') {
|
||||
if (cacheConfig.REDIS.ENABLED) {
|
||||
return await cache.hGet(sessionId, key);
|
||||
} else {
|
||||
if (!(await fileExists(localFile(key)))) return null;
|
||||
@@ -123,8 +126,10 @@ export default async function useMultiFileAuthStatePrisma(
|
||||
|
||||
async function removeData(key: string): Promise<any> {
|
||||
try {
|
||||
const cacheConfig = configService.get<CacheConf>('CACHE');
|
||||
|
||||
if (key != 'creds') {
|
||||
if (process.env.CACHE_REDIS_ENABLED === 'true') {
|
||||
if (cacheConfig.REDIS.ENABLED) {
|
||||
return await cache.hDelete(sessionId, key);
|
||||
} else {
|
||||
await fs.unlink(localFile(key));
|
||||
|
||||
Reference in New Issue
Block a user