import { Controller, Get, ServiceUnavailableException, VERSION_NEUTRAL, } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { PrismaService } from '../prisma/prisma.service'; import { Public } from '../auth/decorators/public.decorator'; @ApiTags('health') @Public() @Controller({ path: 'health', version: VERSION_NEUTRAL }) export class HealthController { constructor(private readonly prisma: PrismaService) {} @Get() liveness(): { status: 'ok' } { return { status: 'ok' }; } @Get('ready') async readiness(): Promise<{ status: 'ok' }> { try { await this.prisma.$queryRaw`SELECT 1`; return { status: 'ok' }; } catch { throw new ServiceUnavailableException('Database not reachable'); } } }