mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-26 02:18:38 -06:00
Start
This commit is contained in:
parent
40c230c7db
commit
a10226bea2
@ -102,6 +102,7 @@ export type Auth = {
|
||||
TYPE: 'jwt' | 'apikey';
|
||||
};
|
||||
|
||||
export type Instances = { LIMIT: number };
|
||||
export type DelInstance = number | boolean;
|
||||
|
||||
export type GlobalWebhook = {
|
||||
@ -124,6 +125,7 @@ export interface Env {
|
||||
DATABASE: Database;
|
||||
REDIS: Redis;
|
||||
LOG: Log;
|
||||
INSTANCES: Instances;
|
||||
DEL_INSTANCE: DelInstance;
|
||||
WEBHOOK: Webhook;
|
||||
CONFIG_SESSION_PHONE: ConfigSessionPhone;
|
||||
@ -255,6 +257,9 @@ export class ConfigService {
|
||||
QRCODE: {
|
||||
LIMIT: Number.parseInt(process.env.QRCODE_LIMIT) || 30,
|
||||
},
|
||||
INSTANCES: {
|
||||
LIMIT: Number.parseInt(process.env.INSTANCES_LIMIT) || 0,
|
||||
},
|
||||
AUTHENTICATION: {
|
||||
TYPE: process.env.AUTHENTICATION_TYPE as 'jwt',
|
||||
API_KEY: {
|
||||
|
@ -44,6 +44,10 @@ LOG:
|
||||
# Determine how long the instance should be deleted from memory in case of no connection.
|
||||
# Default time: 5 minutes
|
||||
# If you don't even want an expiration, enter the value false
|
||||
# Instances settings
|
||||
INSTANCES:
|
||||
# Sets a limit of instances that can be created on the server
|
||||
LIMIT: 0
|
||||
DEL_INSTANCE: false # or false
|
||||
|
||||
# Temporary data storage
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { delay } from '@whiskeysockets/baileys';
|
||||
import EventEmitter2 from 'eventemitter2';
|
||||
import { Auth, ConfigService, HttpServer } from '../../config/env.config';
|
||||
import { Auth, ConfigService, HttpServer, Instances } from '../../config/env.config';
|
||||
import { BadRequestException, InternalServerErrorException } from '../../exceptions';
|
||||
import { InstanceDto } from '../dto/instance.dto';
|
||||
import { RepositoryBroker } from '../repository/repository.manager';
|
||||
@ -47,6 +47,14 @@ export class InstanceController {
|
||||
'The instance name must be lowercase and without special characters',
|
||||
);
|
||||
}
|
||||
|
||||
const INSTANCES_LIMIT = this.configService.get<Instances>('INSTANCES').LIMIT;
|
||||
if (
|
||||
INSTANCES_LIMIT != 0 &&
|
||||
Object.keys(this.waMonitor.waInstances).length >= INSTANCES_LIMIT
|
||||
) {
|
||||
throw new BadRequestException('Limit of instances reached');
|
||||
}
|
||||
|
||||
this.logger.verbose('checking duplicate token');
|
||||
await this.authService.checkDuplicateToken(token);
|
||||
|
Loading…
Reference in New Issue
Block a user