All files / apps/api/src/modules/probe probe.controller.ts

71.42% Statements 25/35
25% Branches 1/4
25% Functions 1/4
71.42% Lines 25/35

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 27 28 29 30 31 32 33 34 35 361x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 1x 1x 1x         1x 1x 1x       1x 1x 1x       1x  
import { Controller, Get } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
 
import { RefreshmentsProbe } from '@amalia/data-capture/imports/core';
import { DatabaseReplicationService } from '@amalia/kernel/bootstrap/database';
import { CalculationsProbe } from '@amalia/payout-calculation/compute-engine/core-lifecycle';
 
@ApiTags('probe')
@Controller('probe')
export class ProbeController {
  public constructor(
    private readonly replicationService: DatabaseReplicationService,
    private readonly calculationsProbe: CalculationsProbe,
    private readonly refreshmentsProbe: RefreshmentsProbe,
  ) {}
 
  @Get('replication')
  public async probeReplication() {
    const MAX_LAG_SECONDS = 5;
    await this.replicationService.probe(MAX_LAG_SECONDS);
    return { ok: true };
  }
 
  @Get('calculations')
  public async probeCalculations() {
    await this.calculationsProbe.probe();
    return { ok: true };
  }
 
  @Get('refreshments')
  public async probeRefreshments() {
    await this.refreshmentsProbe.probe();
    return { ok: true };
  }
}