src/core/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.

Relationships

Used by

Depends on

No results matching.

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 { ApiTags } from "@nestjs/swagger";
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.
 */
@ApiTags("App")
@Controller("health")
export class HealthController {
    constructor(
        private readonly health: HealthCheckService,
        private readonly 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 ""