Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

application specific: add more health checks #358

Open
github-actions bot opened this issue Aug 16, 2022 · 0 comments
Open

application specific: add more health checks #358

github-actions bot opened this issue Aug 16, 2022 · 0 comments
Labels

Comments

@github-actions
Copy link

application specific: add more health checks

See: https://progressivecoder.com/nestjs-health-check-terminus/

() =>

this.http.pingCheck(

'Basic Check',

http://localhost:${this.configService.get('server.port')},

),

// TODO application specific: add more health checks

import { Controller, Get } from '@nestjs/common';
import { Public } from '../auth/authentication.decorator';
import {
  HealthCheck,
  HealthCheckService,
  HttpHealthIndicator,
  TypeOrmHealthIndicator,
} from '@nestjs/terminus';
import { ConfigService } from '@nestjs/config';

@Controller('healthcheck')
export class HealthcheckController {
  constructor(
    private readonly configService: ConfigService,
    private readonly healthcheckService: HealthCheckService,
    private readonly http: HttpHealthIndicator,
    private readonly database: TypeOrmHealthIndicator,
  ) {}

  @Public()
  @HealthCheck()
  @Get()
  async checkHealth(): Promise<any> {
    return this.healthcheckService.check([
      // TODO application specific: add more health checks
      // See: https://progressivecoder.com/nestjs-health-check-terminus/
      // () =>
      // this.http.pingCheck(
      //   'Basic Check',
      //   `http://localhost:${this.configService.get('server.port')}`,
      // ),

      // Database connectivity
      () =>
        this.database.pingCheck(this.configService.get('database.database')),
    ]);
  }
}

f32efda6a9611bfc61ca4447216689f4abd4d544

@github-actions github-actions bot added the todo label Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

0 participants