Skip to content

Commit 62c00c3

Browse files
committed
feat(router): update whatsappWebVersion to fetch latest Baileys version
- Modified the root route to fetch the latest WhatsApp web version from Baileys if not set in the environment configuration. - This enhancement ensures that clients receive the most up-to-date version information in the API response.
1 parent afc2927 commit 62c00c3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/api/routes/index.router.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { ChatbotRouter } from '@api/integrations/chatbot/chatbot.router';
66
import { EventRouter } from '@api/integrations/event/event.router';
77
import { StorageRouter } from '@api/integrations/storage/storage.router';
88
import { configService } from '@config/env.config';
9+
import { fetchLatestBaileysVersion } from 'baileys';
910
import { Router } from 'express';
1011
import fs from 'fs';
1112
import mimeTypes from 'mime-types';
@@ -60,15 +61,16 @@ router.get('/assets/*', (req, res) => {
6061
router
6162
.use((req, res, next) => telemetry.collectTelemetry(req, res, next))
6263

63-
.get('/', (req, res) => {
64+
.get('/', async (req, res) => {
6465
res.status(HttpStatus.OK).json({
6566
status: HttpStatus.OK,
6667
message: 'Welcome to the Evolution API, it is working!',
6768
version: packageJson.version,
6869
clientName: process.env.DATABASE_CONNECTION_CLIENT_NAME,
6970
manager: !serverConfig.DISABLE_MANAGER ? `${req.protocol}://${req.get('host')}/manager` : undefined,
7071
documentation: `https://doc.evolution-api.com`,
71-
whatsappWebVersion: process.env.CONFIG_SESSION_PHONE_VERSION,
72+
whatsappWebVersion:
73+
process.env.CONFIG_SESSION_PHONE_VERSION || (await fetchLatestBaileysVersion()).version.join('.'),
7274
});
7375
})
7476
.post('/verify-creds', authGuard['apikey'], async (req, res) => {

0 commit comments

Comments
 (0)