From eef1338cd2f6507f68383ac324c0acf92f87cd19 Mon Sep 17 00:00:00 2001 From: vchikalkin Date: Mon, 6 Oct 2025 21:50:03 +0300 Subject: [PATCH] Add health check endpoint and controller to cache-proxy service - Implemented a new HealthController in the cache-proxy application to provide a health check endpoint at `/api/health`, returning a simple status response. - Updated the AppModule to include the HealthController, ensuring it is registered within the application. - Configured a health check in the Docker Compose file for the cache-proxy service, allowing for automated health monitoring. --- apps/cache-proxy/src/app.module.ts | 2 ++ apps/cache-proxy/src/health/health.controller.ts | 11 +++++++++++ docker-compose.yml | 5 +++++ 3 files changed, 18 insertions(+) create mode 100644 apps/cache-proxy/src/health/health.controller.ts diff --git a/apps/cache-proxy/src/app.module.ts b/apps/cache-proxy/src/app.module.ts index 72d471b..3b8dc2c 100644 --- a/apps/cache-proxy/src/app.module.ts +++ b/apps/cache-proxy/src/app.module.ts @@ -1,4 +1,5 @@ import { ProxyModule } from './proxy/proxy.module'; +import { HealthController } from './health/health.controller'; import { Global, Module } from '@nestjs/common'; import { ConfigModule } from '@nestjs/config'; @@ -10,6 +11,7 @@ import { ConfigModule } from '@nestjs/config'; }), ProxyModule, ], + controllers: [HealthController], providers: [], }) // eslint-disable-next-line @typescript-eslint/no-extraneous-class diff --git a/apps/cache-proxy/src/health/health.controller.ts b/apps/cache-proxy/src/health/health.controller.ts new file mode 100644 index 0000000..123618b --- /dev/null +++ b/apps/cache-proxy/src/health/health.controller.ts @@ -0,0 +1,11 @@ +import { Controller, Get } from '@nestjs/common'; + +@Controller('api') +export class HealthController { + @Get('health') + public health() { + return { status: 'ok' }; + } +} + + diff --git a/docker-compose.yml b/docker-compose.yml index 6af1f6a..19cd764 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,11 @@ services: networks: - app - web + healthcheck: + test: ['CMD', 'wget', '-qO-', 'http://localhost:5000/api/health'] + interval: 10s + timeout: 3s + retries: 5 web: image: ${DOCKERHUB_USERNAME}/zapishis-web:${WEB_IMAGE_TAG} env_file: