File

apps/api/src/app/app.controller.ts

Index

Methods

Methods

check
check()
Decorators :
@Get('health')
@HealthCheck()
Returns : Promise<HealthCheckResult>
Async getData
getData()
Decorators :
@Get()
Returns : unknown
import { Controller, Get } from '@nestjs/common'

import { AppService } from './app.service'

import {
  HealthCheck,
  HealthCheckResult,
  HealthCheckService,
  MemoryHealthIndicator,
  TypeOrmHealthIndicator
} from '@nestjs/terminus'

@Controller()
export class AppController {
  constructor(
    private readonly appService: AppService,
    private health: HealthCheckService,
    private orm: TypeOrmHealthIndicator,
    private memory: MemoryHealthIndicator
  ) {}

  @Get()
  async getData() {
    return await this.appService.getData()
  }

  @Get('health')
  @HealthCheck()
  check(): Promise<HealthCheckResult> {
    return this.health.check([
      () => this.orm.pingCheck('db'),
      () => this.memory.checkRSS('mem_rss', 768 * 2 ** 20 /* 768 MB */)
    ])
  }
}

results matching ""

    No results matching ""