mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-12-19 03:42:23 -06:00
chore: Updated dependencies and added new manager
In this commit, the following changes were made: - Updated the version of the project to 2.0.4-beta. - Added the new manager with version 2.0.0. - Updated the Baileys version. - Modified several files such as CHANGELOG.md, Dockerfile, package.json, src/api/routes/index.router.ts, and src/api/routes/view.router.ts. - Deleted the views/manager.hbs file and added the manager/ folder. These changes update the dependencies and include a new manager, which may impact the application's functionality.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { Router } from 'express';
|
||||
import fs from 'fs';
|
||||
import mime from 'mime';
|
||||
import path from 'path';
|
||||
|
||||
import { configService, WaBusiness } from '../../config/env.config';
|
||||
import { authGuard } from '../guards/auth.guard';
|
||||
@@ -44,6 +46,20 @@ const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
|
||||
|
||||
if (!serverConfig.DISABLE_MANAGER) router.use('/manager', new ViewsRouter().router);
|
||||
|
||||
router.get('/assets/*', (req, res) => {
|
||||
const fileName = req.params[0];
|
||||
const basePath = path.join(__dirname, '../../../manager/dist');
|
||||
|
||||
const filePath = path.join(basePath, 'assets/', fileName);
|
||||
|
||||
if (fs.existsSync(filePath)) {
|
||||
res.set('Content-Type', mime.lookup(filePath) || 'text/css');
|
||||
res.send(fs.readFileSync(filePath));
|
||||
} else {
|
||||
res.status(404).send('File not found');
|
||||
}
|
||||
});
|
||||
|
||||
router
|
||||
.use((req, res, next) => telemetry.collectTelemetry(req, res, next))
|
||||
|
||||
|
||||
@@ -1,34 +1,25 @@
|
||||
import { Router } from 'express';
|
||||
import fs from 'fs';
|
||||
import mime from 'mime-types';
|
||||
import express, { Router } from 'express';
|
||||
import path from 'path';
|
||||
|
||||
import { RouterBroker } from '../abstract/abstract.router';
|
||||
|
||||
export class ViewsRouter extends RouterBroker {
|
||||
public readonly router: Router;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this.router = Router();
|
||||
|
||||
const basePath = 'evolution-manager/dist';
|
||||
const basePath = path.join(__dirname, '../../../manager/dist');
|
||||
const indexPath = path.join(basePath, 'index.html');
|
||||
|
||||
const indexPath = require.resolve(`${basePath}/index.html`);
|
||||
console.log('Base path:', basePath);
|
||||
console.log('Index path:', indexPath);
|
||||
|
||||
this.router.get('/*', (req, res) => {
|
||||
try {
|
||||
const pathname = req.url.split('?')[0];
|
||||
this.router.use(express.static(basePath));
|
||||
|
||||
// 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));
|
||||
}
|
||||
this.router.get('*', (req, res) => {
|
||||
res.sendFile(indexPath);
|
||||
});
|
||||
}
|
||||
|
||||
public readonly router = Router();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user