Skip to content

Commit

Permalink
Merge pull request #250 from gabrielpastori1/manager
Browse files Browse the repository at this point in the history
Add Manager
  • Loading branch information
DavidsonGomes authored Dec 11, 2023
2 parents 87a8e25 + b2e144f commit 87baec5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 28 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 0 additions & 23 deletions src/whatsapp/controllers/views.controller.ts

This file was deleted.

24 changes: 21 additions & 3 deletions src/whatsapp/routers/view.router.ts
Original file line number Diff line number Diff line change
@@ -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));
}
});
}

Expand Down
2 changes: 0 additions & 2 deletions src/whatsapp/whatsapp.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 87baec5

Please sign in to comment.