26 lines
600 B
TypeScript
26 lines
600 B
TypeScript
import { Controller, Get } from '@nestjs/common';
|
|
import { ApiTags, ApiOperation } from '@nestjs/swagger';
|
|
import { PrismaService } from './prisma/prisma.service';
|
|
|
|
@ApiTags('Health')
|
|
@Controller('health')
|
|
export class HealthController {
|
|
constructor(private prisma: PrismaService) {}
|
|
|
|
@Get()
|
|
@ApiOperation({ summary: 'Health check' })
|
|
async check() {
|
|
let dbStatus = 'ok';
|
|
try {
|
|
await this.prisma.$queryRaw`SELECT 1`;
|
|
} catch {
|
|
dbStatus = 'error';
|
|
}
|
|
|
|
return {
|
|
status: 'ok',
|
|
database: dbStatus,
|
|
timestamp: new Date().toISOString(),
|
|
};
|
|
}
|
|
} |