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 20 21 22 23 | 22x 102x 102x 1x 101x | import { HealthChecker } from '../../domain/health/health-checker';
import { DatabaseUnavailableError } from '../../domain/health/errors/database-unavailable.error';
import { HealthReport } from '../../domain/health/health-report';
export class CheckHealthUseCase {
constructor(private readonly healthChecker: HealthChecker) {}
async execute(): Promise<HealthReport> {
const isDatabaseUp = await this.healthChecker.checkDatabase();
if (!isDatabaseUp) {
throw new DatabaseUnavailableError();
}
return {
status: 'ok',
uptimeSeconds: Math.floor(process.uptime()),
timestamp: new Date().toISOString(),
database: 'up',
};
}
}
|