diff --git a/src/health/health.controller.ts b/src/health/health.controller.ts index fb2ba09..972e4b2 100644 --- a/src/health/health.controller.ts +++ b/src/health/health.controller.ts @@ -1,7 +1,6 @@ -import {Controller, Get, Injectable, Res} from '@nestjs/common'; +import {Controller, Get, Injectable} from '@nestjs/common'; import pTimeout from 'p-timeout'; import * as db from 'zapatos/db'; -import {FastifyReply} from 'fastify'; import {PoolService} from '~/pool/pool.service'; @Controller('health') @@ -10,18 +9,18 @@ export class HealthController { constructor(private readonly pool: PoolService) {} @Get() - async getHealth(@Res() reply: FastifyReply) { + async getHealth() { const [canConnectToDatabase, arePendingJobs, haveJobsErrored] = await Promise.all([ this.canConnectToDatabase(), this.arePendingJobs(), this.haveJobsErrored() ].map(async p => pTimeout(p, 2000).catch(() => -1))); - await reply.status(canConnectToDatabase ? 200 : 503).send({ + return { canConnectToDatabase, arePendingJobs, haveJobsErrored, - }); + }; } private async canConnectToDatabase() {