mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2026-02-05 23:06:26 -06:00
Refactored WAMonitoringService to retrieve instances using Prisma's `findMany` method with a dynamic `where` clause. This change simplifies the code and makes it more maintainable. It also removes the deprecated `for...of` loop and the unnecessary instantiation of objects. The new implementation provides better performance and is more aligned with the current best practices. Modified files: - src/api/services/monitor.service.ts
23 lines
546 B
TypeScript
23 lines
546 B
TypeScript
import { BadRequestException } from '../../exceptions';
|
|
import { PrismaRepository } from '../repository/repository.service';
|
|
|
|
export class AuthService {
|
|
constructor(private readonly prismaRepository: PrismaRepository) {}
|
|
|
|
public async checkDuplicateToken(token: string) {
|
|
if (!token) {
|
|
return true;
|
|
}
|
|
|
|
const instances = await this.prismaRepository.instance.findMany({
|
|
where: { token },
|
|
});
|
|
|
|
if (instances.length > 0) {
|
|
throw new BadRequestException('Token already exists');
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|