chore: carry over lab3 implementation

This commit is contained in:
2026-11-05 12:31:02 +03:00
parent ec540a1a72
commit 4ffde2494c
73 changed files with 14538 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
import { Controller, Get } from '@nestjs/common';
import { ApiError } from '../common/filters/api-error';
import { PrismaService } from '../db/prisma.service';
import { isDraining } from './shutdown';
@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' }> {
if (isDraining()) {
throw new ApiError('unavailable', 'shutting down');
}
try {
await this.prisma.$queryRaw`SELECT 1`;
} catch {
throw new ApiError('unavailable', 'database unavailable');
}
return { status: 'ok' };
}
}