Files
mtusi2026lab3/src/health/health.controller.ts
T
2026-11-01 13:37:02 +03:00

24 lines
564 B
TypeScript

import { Controller, Get } from '@nestjs/common';
import { ApiError } from '../common/filters/api-error';
import { PrismaService } from '../db/prisma.service';
@Controller('health')
export class HealthController {
constructor(private readonly prisma: PrismaService) {}
@Get('live')
live(): { status: 'ok' } {
return { status: 'ok' };
}
@Get('ready')
async ready(): Promise<{ status: 'ok' }> {
try {
await this.prisma.$queryRaw`SELECT 1`;
} catch {
throw new ApiError('unavailable', 'database unavailable');
}
return { status: 'ok' };
}
}