From 1c0eff92f87121499f3e76231e14b256ed569f5b Mon Sep 17 00:00:00 2001 From: Stefan Printezis Date: Thu, 14 Sep 2023 18:00:36 +0300 Subject: [PATCH] fix(mikro-orm.health): mikro-orm connection `type` is deprecated Use the abstraction provided by MikroOrm to determine connection status. resolves #2325 --- .../database/mikro-orm.health.ts | 25 +++---------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/lib/health-indicator/database/mikro-orm.health.ts b/lib/health-indicator/database/mikro-orm.health.ts index 48e3bfc1b..10d578997 100644 --- a/lib/health-indicator/database/mikro-orm.health.ts +++ b/lib/health-indicator/database/mikro-orm.health.ts @@ -1,6 +1,6 @@ -import { Injectable, NotImplementedException, Scope } from '@nestjs/common'; +import { Injectable, Scope } from '@nestjs/common'; import { ModuleRef } from '@nestjs/core'; -import { HealthCheckError } from '../../health-check/health-check.error'; +import { HealthCheckError } from '../../health-check'; import * as MikroOrm from '@mikro-orm/core'; import { TimeoutError } from '../../errors'; @@ -121,24 +121,7 @@ export class MikroOrmHealthIndicator extends HealthIndicator { * */ private async pingDb(connection: MikroOrm.Connection, timeout: number) { - let check: Promise; - const type = connection.getPlatform().getConfig().get('type'); - - switch (type) { - case 'postgresql': - case 'mysql': - case 'mariadb': - case 'sqlite': - check = connection.execute('SELECT 1'); - break; - case 'mongo': - check = connection.isConnected(); - break; - default: - throw new NotImplementedException( - `${type} ping check is not implemented yet`, - ); - } - return await promiseTimeout(timeout, check); + const isConnected = connection.isConnected(); + return await promiseTimeout(timeout, isConnected); } }