File

src/health/health.controller.ts

Prefix

health

Description

HealthController is responsible for providing health check endpoints. It uses the HealthCheckService to perform checks on the database connection.

Index

Methods

Methods

check
check()
Decorators :
@Get()
@HealthCheck()

Endpoint to check the health of the service.

Returns : any
import { Controller, Get } from '@nestjs/common';
import {
    HealthCheck,
    HealthCheckService,
    TypeOrmHealthIndicator,
} from '@nestjs/terminus';

/**
 * HealthController is responsible for providing health check endpoints.
 * It uses the HealthCheckService to perform checks on the database connection.
 */
@Controller('health')
export class HealthController {
    constructor(
        private health: HealthCheckService,
        private db: TypeOrmHealthIndicator,
    ) {}

    /**
     * Endpoint to check the health of the service.
     * @returns
     */
    @Get()
    @HealthCheck()
    check() {
        return this.health.check([() => this.db.pingCheck('database')]);
    }
}

results matching ""

    No results matching ""