mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-13 15:14:49 -06:00
commit
87baec5ff8
@ -56,6 +56,7 @@
|
||||
"cross-env": "^7.0.3",
|
||||
"dayjs": "^1.11.7",
|
||||
"eventemitter2": "^6.4.9",
|
||||
"evolution-manager": "latest",
|
||||
"exiftool-vendored": "^22.0.0",
|
||||
"express": "^4.18.2",
|
||||
"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 fs from 'fs';
|
||||
import mime from 'mime-types';
|
||||
|
||||
import { RouterBroker } from '../abstract/abstract.router';
|
||||
import { viewsController } from '../whatsapp.module';
|
||||
|
||||
export class ViewsRouter extends RouterBroker {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.router.get('/', (req, res) => {
|
||||
return viewsController.manager(req, res);
|
||||
const basePath = 'evolution-manager/dist';
|
||||
|
||||
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 { SqsController } from './controllers/sqs.controller';
|
||||
import { TypebotController } from './controllers/typebot.controller';
|
||||
import { ViewsController } from './controllers/views.controller';
|
||||
import { WebhookController } from './controllers/webhook.controller';
|
||||
import { WebsocketController } from './controllers/websocket.controller';
|
||||
import {
|
||||
@ -154,7 +153,6 @@ export const instanceController = new InstanceController(
|
||||
typebotService,
|
||||
cache,
|
||||
);
|
||||
export const viewsController = new ViewsController(waMonitor, configService);
|
||||
export const sendMessageController = new SendMessageController(waMonitor);
|
||||
export const chatController = new ChatController(waMonitor);
|
||||
export const groupController = new GroupController(waMonitor);
|
||||
|
Loading…
Reference in New Issue
Block a user