[core] Add engine to version (fix #156)
This commit is contained in:
1 parent
c46bc1b923
commit
a3ead95ea4
3 files changed
+13
-3
No files matched your search
@@ -4,6 +4,7 @@ import { ConfigService } from '@nestjs/config';
|
||||
import { parseBool } from './helpers';
|
||||
import { WAHAEngine } from './structures/enums.dto';
|
||||
import { WebhookConfig } from './structures/webhooks.config.dto';
|
||||
import { getEngineName } from './version';
|
||||
|
||||
@Injectable()
|
||||
export class WhatsappConfigService {
|
||||
@@ -100,13 +101,14 @@ export class WhatsappConfigService {
|
||||
}
|
||||
|
||||
getDefaultEngineName(): WAHAEngine {
|
||||
const value = this.get('WHATSAPP_DEFAULT_ENGINE', WAHAEngine.WEBJS);
|
||||
const value = getEngineName();
|
||||
if (value in WAHAEngine) {
|
||||
return WAHAEngine[value];
|
||||
}
|
||||
console.log(
|
||||
`Unknown WhatsApp default engine, using WEBJS. WHATSAPP_DEFAULT_ENGINE=${value}`,
|
||||
`Unknown WhatsApp default engine WHATSAPP_DEFAULT_ENGINE=${value}. Using WEBJS`,
|
||||
);
|
||||
return WAHAEngine.WEBJS;
|
||||
}
|
||||
|
||||
get(name: string, defaultValue = undefined): any {
|
||||
|
||||
+2
-1
@@ -5,7 +5,7 @@ import { AllExceptionsFilter } from './api/exception.filter';
|
||||
import { WhatsappConfigService } from './config.service';
|
||||
import { AppModuleCore } from './core/app.module.core';
|
||||
import { SwaggerModuleCore } from './core/swagger.module.core';
|
||||
import { getWAHAVersion, WAHAVersion } from './version';
|
||||
import { getWAHAVersion, VERSION, WAHAVersion } from './version';
|
||||
import { WAHA_WEBHOOKS } from './structures/webhooks.dto';
|
||||
|
||||
async function loadModules(): Promise<
|
||||
@@ -50,6 +50,7 @@ async function bootstrap() {
|
||||
const config = app.get(WhatsappConfigService);
|
||||
await app.listen(config.port);
|
||||
console.log(`WhatsApp HTTP API is running on: ${await app.getUrl()}`);
|
||||
console.log(`Environment:`, VERSION);
|
||||
}
|
||||
|
||||
bootstrap();
|
||||
@@ -1,5 +1,6 @@
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
import { getBrowserExecutablePath } from './core/abc/session.abc';
|
||||
import { WAHAEngine } from './structures/enums.dto';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const fs = require('fs');
|
||||
@@ -24,9 +25,15 @@ export function getWAHAVersion(): WAHAVersion {
|
||||
|
||||
return WAHAVersion.CORE;
|
||||
}
|
||||
export function getEngineName(): string {
|
||||
// Load engine name from WHATSAPP_DEFAULT_ENGINE environment variable
|
||||
// If not set - use WEBJS
|
||||
return process.env.WHATSAPP_DEFAULT_ENGINE || WAHAEngine.WEBJS;
|
||||
}
|
||||
|
||||
export const VERSION = {
|
||||
version: '2023.10.12',
|
||||
engine: getEngineName(),
|
||||
tier: getWAHAVersion(),
|
||||
browser: getBrowserExecutablePath(),
|
||||
};
|
||||
Reference in new issue
Block a user