26 lines
672 B
TypeScript
26 lines
672 B
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import {
|
|
HealthCheckError,
|
|
HealthIndicator,
|
|
HealthIndicatorResult,
|
|
} from '@nestjs/terminus';
|
|
import { UsersRepository } from '../../../user/adapters/secondaries/users.repository';
|
|
|
|
@Injectable()
|
|
export class PrismaHealthIndicatorUseCase extends HealthIndicator {
|
|
constructor(private readonly repository: UsersRepository) {
|
|
super();
|
|
}
|
|
|
|
isHealthy = async (key: string): Promise<HealthIndicatorResult> => {
|
|
try {
|
|
await this.repository.healthCheck();
|
|
return this.getStatus(key, true);
|
|
} catch (e) {
|
|
throw new HealthCheckError('Prisma', {
|
|
prisma: e.message,
|
|
});
|
|
}
|
|
};
|
|
}
|