Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 11x 11x 11x 11x 11x 11x | import { Injectable } from '@nestjs/common';
import { HealthCheckError, HealthIndicator, HealthIndicatorResult } from '@nestjs/terminus';
import { PrismaService } from '@app/modules/prisma/prisma.service';
@Injectable()
export class PrismaHealthIndicatorService extends HealthIndicator {
constructor(private readonly prisma: PrismaService) {
super();
}
async isHealthy(key = 'prisma'): Promise<HealthIndicatorResult> {
try {
await this.prisma.client.$queryRaw`SELECT 1`;
return this.getStatus(key, true);
} catch (_error) {
throw new HealthCheckError('Prisma ping failed', this.getStatus(key, false));
}
}
} |