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.
This commit is contained in:
vchikalkin 2025-10-06 21:50:03 +03:00
parent 50ef49d01f
commit eef1338cd2
3 changed files with 18 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1,11 @@
import { Controller, Get } from '@nestjs/common';
@Controller('api')
export class HealthController {
@Get('health')
public health() {
return { status: 'ok' };
}
}

View File

@ -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: