From 52ef8e8b762d5b56bc0b2f22f2f102f0b8bacf40 Mon Sep 17 00:00:00 2001 From: devlikepro Date: Thu, 25 Jul 2024 17:57:40 +0300 Subject: [PATCH] [core] Add /ping --- src/api/ping.controller.ts | 13 +++++++++++++ src/core/app.module.core.ts | 2 ++ src/structures/ping.dto.ts | 3 +++ 3 files changed, 18 insertions(+) create mode 100644 src/api/ping.controller.ts create mode 100644 src/structures/ping.dto.ts diff --git a/src/api/ping.controller.ts b/src/api/ping.controller.ts new file mode 100644 index 00000000..8d0a59c0 --- /dev/null +++ b/src/api/ping.controller.ts @@ -0,0 +1,13 @@ +import { Controller, Get } from '@nestjs/common'; +import { ApiOperation, ApiTags } from '@nestjs/swagger'; +import { PingResponse } from '@waha/structures/ping.dto'; + +@Controller('ping') +@ApiTags('other') +export class PingController { + @Get() + @ApiOperation({ summary: 'Ping the server, perform no operations.' }) + ping(): PingResponse { + return { message: 'pong' }; + } +} diff --git a/src/core/app.module.core.ts b/src/core/app.module.core.ts index b975ee9d..9b7d1ef8 100644 --- a/src/core/app.module.core.ts +++ b/src/core/app.module.core.ts @@ -18,6 +18,7 @@ import { ChattingController } from '../api/chatting.controller'; import { ContactsController } from '../api/contacts.controller'; import { GroupsController } from '../api/groups.controller'; import { HealthController } from '../api/health.controller'; +import { PingController } from '../api/ping.controller'; import { PresenceController } from '../api/presence.controller'; import { ScreenshotController } from '../api/screenshot.controller'; import { @@ -105,6 +106,7 @@ export const CONTROLLERS = [ ScreenshotController, VersionController, HealthController, + PingController, ]; const PROVIDERS = [ { diff --git a/src/structures/ping.dto.ts b/src/structures/ping.dto.ts new file mode 100644 index 00000000..5542db38 --- /dev/null +++ b/src/structures/ping.dto.ts @@ -0,0 +1,3 @@ +export class PingResponse { + message: string = 'pong'; +}