[core] Simplify /api/server/status

This commit is contained in:
devlikepro committed 2024-08-27 16:42:58 +07:00
1 parent cc9c9e2253
commit 65eabf6153
2 files changed
+4 -22

No files matched your search

+4 -8
View File
@@ -9,9 +9,8 @@ import {
Query,
UsePipes,
} from '@nestjs/common';
import { UnprocessableEntityException } from '@nestjs/common/exceptions/unprocessable-entity.exception';
import { ApiOperation, ApiSecurity, ApiTags } from '@nestjs/swagger';
import { getApp, getAppModuleInstance } from '@waha/main';
import { getApp } from '@waha/main';
import { WAHAValidationPipe } from '@waha/nestjs/pipes/WAHAValidationPipe';
import { WAHAEnvironment } from '@waha/structures/environment.dto';
import {
@@ -67,15 +66,12 @@ export class ServerController {
@Get('status')
@ApiOperation({ summary: 'The server status' })
async status(): Promise<ServerStatusResponse> {
const appModule = await getAppModuleInstance();
if (!appModule) {
throw new UnprocessableEntityException('AppModule not found');
}
const now = Date.now();
const startTimestamp = appModule.startTimestamp;
const uptime = Math.floor(process.uptime() * 1000);
const startTimestamp = now - uptime;
return {
startTimestamp: startTimestamp,
uptime: now - startTimestamp,
uptime: uptime,
};
}
-14
View File
@@ -57,20 +57,6 @@ export function getApp() {
return app;
}
/**
* Get the AppModule instance (depends on the version)
*/
export async function getAppModuleInstance(): Promise<
AppModuleCore | undefined
> {
const [AppModule, _] = await loadModules();
const app = getApp();
if (!app) {
return;
}
return app.get(AppModule);
}
async function bootstrap() {
const version = getWAHAVersion();
logger.info(`WAHA (WhatsApp HTTP API) - Running ${version} version...`);