@neoskop/nestjs-probes
Version:
22 lines (19 loc) • 731 B
text/typescript
import { Controller, Get, HttpStatus, Param, Res } from '@nestjs/common';
import { Response } from 'express';
import { PROBE_NOT_OKAY, PROBE_OKAY } from './probes.constants';
import { ProbesService } from './probes.service';
import { ProbeType } from './types';
('probes')
export class ProbeController {
constructor(private readonly probesService: ProbesService) {}
(':probeName')
public async checkProbe(
('probeName') probeName: ProbeType,
() res: Response,
) {
const succeeded = await this.probesService.checkProbe(probeName);
res
.status(succeeded ? HttpStatus.OK : HttpStatus.SERVICE_UNAVAILABLE)
.json({ status: succeeded ? PROBE_OKAY : PROBE_NOT_OKAY });
}
}