Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mikro-orm.health): mikro-orm connection type is deprecated #2325

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 4 additions & 21 deletions lib/health-indicator/database/mikro-orm.health.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -121,24 +121,7 @@ export class MikroOrmHealthIndicator extends HealthIndicator {
*
*/
private async pingDb(connection: MikroOrm.Connection, timeout: number) {
let check: Promise<any>;
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);
}
}