All files / src/modules/common/health/controllers health.api.controller.ts

100% Statements 14/14
100% Branches 0/0
100% Functions 3/3
100% Lines 11/11

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 24 25 26 271x 1x 1x 1x 1x         1x   1x 1x                 1x 1x 1x      
import { Controller, Get } from '@nestjs/common';
import { HealthService } from '../services/health.service';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { HealthCheck, HealthCheckService } from '@nestjs/terminus';
import { pick } from 'lodash';
 
@ApiTags('Health')
@Controller({ path: 'api/health-check' })
@Controller()
export class HealthApiController {
  constructor(
    private readonly health: HealthCheckService,
    private readonly healthService: HealthService,
  ) {}
 
  @Get()
  @ApiOperation({
    operationId: 'healthCheck',
    description: 'Get ping check health',
  })
  @HealthCheck()
  async healthCheck() {
    const result = await this.health.check([() => this.healthService.getHello()]);
    return pick(result, 'status', 'details');
  }
}