mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-26 18:38:39 -06:00
Start
This commit is contained in:
parent
40c230c7db
commit
a10226bea2
@ -102,6 +102,7 @@ export type Auth = {
|
|||||||
TYPE: 'jwt' | 'apikey';
|
TYPE: 'jwt' | 'apikey';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type Instances = { LIMIT: number };
|
||||||
export type DelInstance = number | boolean;
|
export type DelInstance = number | boolean;
|
||||||
|
|
||||||
export type GlobalWebhook = {
|
export type GlobalWebhook = {
|
||||||
@ -124,6 +125,7 @@ export interface Env {
|
|||||||
DATABASE: Database;
|
DATABASE: Database;
|
||||||
REDIS: Redis;
|
REDIS: Redis;
|
||||||
LOG: Log;
|
LOG: Log;
|
||||||
|
INSTANCES: Instances;
|
||||||
DEL_INSTANCE: DelInstance;
|
DEL_INSTANCE: DelInstance;
|
||||||
WEBHOOK: Webhook;
|
WEBHOOK: Webhook;
|
||||||
CONFIG_SESSION_PHONE: ConfigSessionPhone;
|
CONFIG_SESSION_PHONE: ConfigSessionPhone;
|
||||||
@ -255,6 +257,9 @@ export class ConfigService {
|
|||||||
QRCODE: {
|
QRCODE: {
|
||||||
LIMIT: Number.parseInt(process.env.QRCODE_LIMIT) || 30,
|
LIMIT: Number.parseInt(process.env.QRCODE_LIMIT) || 30,
|
||||||
},
|
},
|
||||||
|
INSTANCES: {
|
||||||
|
LIMIT: Number.parseInt(process.env.INSTANCES_LIMIT) || 0,
|
||||||
|
},
|
||||||
AUTHENTICATION: {
|
AUTHENTICATION: {
|
||||||
TYPE: process.env.AUTHENTICATION_TYPE as 'jwt',
|
TYPE: process.env.AUTHENTICATION_TYPE as 'jwt',
|
||||||
API_KEY: {
|
API_KEY: {
|
||||||
|
@ -44,6 +44,10 @@ LOG:
|
|||||||
# Determine how long the instance should be deleted from memory in case of no connection.
|
# Determine how long the instance should be deleted from memory in case of no connection.
|
||||||
# Default time: 5 minutes
|
# Default time: 5 minutes
|
||||||
# If you don't even want an expiration, enter the value false
|
# 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
|
DEL_INSTANCE: false # or false
|
||||||
|
|
||||||
# Temporary data storage
|
# Temporary data storage
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { delay } from '@whiskeysockets/baileys';
|
import { delay } from '@whiskeysockets/baileys';
|
||||||
import EventEmitter2 from 'eventemitter2';
|
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 { BadRequestException, InternalServerErrorException } from '../../exceptions';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
import { RepositoryBroker } from '../repository/repository.manager';
|
import { RepositoryBroker } from '../repository/repository.manager';
|
||||||
@ -48,6 +48,14 @@ export class InstanceController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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');
|
this.logger.verbose('checking duplicate token');
|
||||||
await this.authService.checkDuplicateToken(token);
|
await this.authService.checkDuplicateToken(token);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user