mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-25 06:37:45 -06:00
adjust in store files
This commit is contained in:
@@ -5,6 +5,9 @@ import { MessageUpRepository } from './messageUp.repository';
|
||||
import { MongoClient } from 'mongodb';
|
||||
import { WebhookRepository } from './webhook.repository';
|
||||
import { AuthRepository } from './auth.repository';
|
||||
import { Auth, ConfigService, Database } from '../../config/env.config';
|
||||
import { execSync } from 'child_process';
|
||||
import { join } from 'path';
|
||||
|
||||
export class RepositoryBroker {
|
||||
constructor(
|
||||
@@ -14,9 +17,11 @@ export class RepositoryBroker {
|
||||
public readonly messageUpdate: MessageUpRepository,
|
||||
public readonly webhook: WebhookRepository,
|
||||
public readonly auth: AuthRepository,
|
||||
private configService: ConfigService,
|
||||
dbServer?: MongoClient,
|
||||
) {
|
||||
this.dbClient = dbServer;
|
||||
this.__init_repo_without_db__();
|
||||
}
|
||||
|
||||
private dbClient?: MongoClient;
|
||||
@@ -24,4 +29,22 @@ export class RepositoryBroker {
|
||||
public get dbServer() {
|
||||
return this.dbClient;
|
||||
}
|
||||
|
||||
private __init_repo_without_db__() {
|
||||
if (!this.configService.get<Database>('DATABASE').ENABLED) {
|
||||
const storePath = join(process.cwd(), 'store');
|
||||
execSync(
|
||||
`mkdir -p ${join(
|
||||
storePath,
|
||||
'auth',
|
||||
this.configService.get<Auth>('AUTHENTICATION').TYPE,
|
||||
)}`,
|
||||
);
|
||||
execSync(`mkdir -p ${join(storePath, 'chats')}`);
|
||||
execSync(`mkdir -p ${join(storePath, 'contacts')}`);
|
||||
execSync(`mkdir -p ${join(storePath, 'messages')}`);
|
||||
execSync(`mkdir -p ${join(storePath, 'message-up')}`);
|
||||
execSync(`mkdir -p ${join(storePath, 'webhook')}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user