Team Ai
Apppublic

oex2003/evolution-api

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
proxy.service.ts33 linesDownload Raw Back to services
1import { InstanceDto } from '@api/dto/instance.dto';2import { ProxyDto } from '@api/dto/proxy.dto';3import { Logger } from '@config/logger.config';4import { Proxy } from '@prisma/client';5 6import { WAMonitoringService } from './monitor.service';7 8export class ProxyService {9  constructor(private readonly waMonitor: WAMonitoringService) {}10 11  private readonly logger = new Logger('ProxyService');12 13  public create(instance: InstanceDto, data: ProxyDto) {14    this.waMonitor.waInstances[instance.instanceName].setProxy(data);15 16    return { proxy: { ...instance, proxy: data } };17  }18 19  public async find(instance: InstanceDto): Promise<Proxy> {20    try {21      const result = await this.waMonitor.waInstances[instance.instanceName].findProxy();22 23      if (Object.keys(result).length === 0) {24        throw new Error('Proxy not found');25      }26 27      return result;28    } catch (error) {29      return null;30    }31  }32}33