mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 09:51:24 -06:00
add manager
This commit is contained in:
parent
d14505d59a
commit
b2e144f35c
@ -56,6 +56,7 @@
|
|||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"dayjs": "^1.11.7",
|
"dayjs": "^1.11.7",
|
||||||
"eventemitter2": "^6.4.9",
|
"eventemitter2": "^6.4.9",
|
||||||
|
"evolution-manager": "latest",
|
||||||
"exiftool-vendored": "^22.0.0",
|
"exiftool-vendored": "^22.0.0",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"express-async-errors": "^3.1.1",
|
"express-async-errors": "^3.1.1",
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
import { Request, Response } from 'express';
|
|
||||||
|
|
||||||
import { Auth, ConfigService, HttpServer } from '../../config/env.config';
|
|
||||||
import { HttpStatus } from '../routers/index.router';
|
|
||||||
import { WAMonitoringService } from '../services/monitor.service';
|
|
||||||
|
|
||||||
export class ViewsController {
|
|
||||||
constructor(private readonly waMonitor: WAMonitoringService, private readonly configService: ConfigService) {}
|
|
||||||
|
|
||||||
public async manager(request: Request, response: Response) {
|
|
||||||
try {
|
|
||||||
const token = this.configService.get<Auth>('AUTHENTICATION').API_KEY.KEY;
|
|
||||||
const port = this.configService.get<HttpServer>('SERVER').PORT;
|
|
||||||
|
|
||||||
const instances = await this.waMonitor.instanceInfo();
|
|
||||||
|
|
||||||
console.log('INSTANCES: ', instances);
|
|
||||||
return response.status(HttpStatus.OK).render('manager', { token, port, instances });
|
|
||||||
} catch (error) {
|
|
||||||
console.log('ERROR: ', error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +1,32 @@
|
|||||||
import { Router } from 'express';
|
import { Router } from 'express';
|
||||||
|
import fs from 'fs';
|
||||||
|
import mime from 'mime-types';
|
||||||
|
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
import { RouterBroker } from '../abstract/abstract.router';
|
||||||
import { viewsController } from '../whatsapp.module';
|
|
||||||
|
|
||||||
export class ViewsRouter extends RouterBroker {
|
export class ViewsRouter extends RouterBroker {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.router.get('/', (req, res) => {
|
const basePath = 'evolution-manager/dist';
|
||||||
return viewsController.manager(req, res);
|
|
||||||
|
const indexPath = require.resolve(`${basePath}/index.html`);
|
||||||
|
|
||||||
|
this.router.get('/*', (req, res) => {
|
||||||
|
try {
|
||||||
|
const pathname = req.url.split('?')[0];
|
||||||
|
|
||||||
|
// verify if url is a file in dist folder
|
||||||
|
if (pathname === '/') throw {};
|
||||||
|
const filePath = require.resolve(`${basePath}${pathname}`);
|
||||||
|
|
||||||
|
const contentType = mime.lookup(filePath) || 'text/plain';
|
||||||
|
res.set('Content-Type', contentType);
|
||||||
|
res.end(fs.readFileSync(filePath));
|
||||||
|
} catch {
|
||||||
|
res.set('Content-Type', 'text/html');
|
||||||
|
res.send(fs.readFileSync(indexPath));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,6 @@ import { SendMessageController } from './controllers/sendMessage.controller';
|
|||||||
import { SettingsController } from './controllers/settings.controller';
|
import { SettingsController } from './controllers/settings.controller';
|
||||||
import { SqsController } from './controllers/sqs.controller';
|
import { SqsController } from './controllers/sqs.controller';
|
||||||
import { TypebotController } from './controllers/typebot.controller';
|
import { TypebotController } from './controllers/typebot.controller';
|
||||||
import { ViewsController } from './controllers/views.controller';
|
|
||||||
import { WebhookController } from './controllers/webhook.controller';
|
import { WebhookController } from './controllers/webhook.controller';
|
||||||
import { WebsocketController } from './controllers/websocket.controller';
|
import { WebsocketController } from './controllers/websocket.controller';
|
||||||
import {
|
import {
|
||||||
@ -154,7 +153,6 @@ export const instanceController = new InstanceController(
|
|||||||
typebotService,
|
typebotService,
|
||||||
cache,
|
cache,
|
||||||
);
|
);
|
||||||
export const viewsController = new ViewsController(waMonitor, configService);
|
|
||||||
export const sendMessageController = new SendMessageController(waMonitor);
|
export const sendMessageController = new SendMessageController(waMonitor);
|
||||||
export const chatController = new ChatController(waMonitor);
|
export const chatController = new ChatController(waMonitor);
|
||||||
export const groupController = new GroupController(waMonitor);
|
export const groupController = new GroupController(waMonitor);
|
||||||
|
Loading…
Reference in New Issue
Block a user