Skip to content

Commit f805f54

Browse files
committed
chore: clean up deprecated third party api
1 parent 00b3f62 commit f805f54

File tree

6 files changed

+248
-15
lines changed

6 files changed

+248
-15
lines changed

lib/health-indicator/database/database-ping-check-settings.interface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* The settings for the typeorm ping check
33
*/
44
import { Connection as MongooseConnection } from 'mongoose';
5-
import { Connection } from 'typeorm';
5+
import { DataSource } from 'typeorm';
66

77
/**
88
* @publicApi
@@ -11,7 +11,7 @@ export interface DatabasePingCheckSettings {
1111
/**
1212
* The connection which the ping check should get executed
1313
*/
14-
connection?: Connection | MongooseConnection;
14+
connection?: DataSource | MongooseConnection;
1515
/**
1616
* The amount of time the check should require in ms
1717
*/

lib/health-indicator/database/typeorm.health.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ export class TypeOrmHealthIndicator extends HealthIndicator {
5858
/**
5959
* Returns the connection of the current DI context
6060
*/
61-
private getContextConnection(): TypeOrm.Connection | null {
62-
const { getConnectionToken } =
61+
private getContextConnection(): TypeOrm.DataSource | null {
62+
const { getDataSourceToken } =
6363
// eslint-disable-next-line @typescript-eslint/no-var-requires
6464
require('@nestjs/typeorm/dist/common/typeorm.utils') as typeof NestJSTypeOrm;
6565

6666
try {
67-
return this.moduleRef.get(getConnectionToken() as string, {
67+
return this.moduleRef.get(getDataSourceToken() as string, {
6868
strict: false,
6969
});
7070
} catch (err) {
@@ -96,7 +96,7 @@ export class TypeOrmHealthIndicator extends HealthIndicator {
9696
* @param timeout The timeout how long the ping should maximum take
9797
*
9898
*/
99-
private async pingDb(connection: TypeOrm.Connection, timeout: number) {
99+
private async pingDb(connection: TypeOrm.DataSource, timeout: number) {
100100
let check: Promise<any>;
101101
switch (connection.options.type) {
102102
case 'mongodb':
@@ -131,7 +131,7 @@ export class TypeOrmHealthIndicator extends HealthIndicator {
131131
let isHealthy = false;
132132
this.checkDependantPackages();
133133

134-
const connection: TypeOrm.Connection | null =
134+
const connection: TypeOrm.DataSource | null =
135135
options.connection || this.getContextConnection();
136136
const timeout = options.timeout || 1000;
137137

lib/health-indicator/microservice/grpc.health.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { HealthCheckError } from '../../health-check/health-check.error';
22
import { Injectable, Scope } from '@nestjs/common';
33
import type * as NestJSMicroservices from '@nestjs/microservices';
44
import { join } from 'path';
5-
import { Observable } from 'rxjs';
5+
import { Observable, lastValueFrom } from 'rxjs';
66
import {
77
HealthIndicatorResult,
88
TimeoutError,
@@ -184,7 +184,7 @@ export class GRPCHealthIndicator extends HealthIndicator {
184184
package: 'grpc.health.v1',
185185
protoPath: join(__dirname, './protos/health.proto'),
186186
healthServiceCheck: (healthService: GRPCHealthService, service: string) =>
187-
healthService.check({ service }).toPromise(),
187+
lastValueFrom(healthService.check({ service })),
188188
timeout: 1000,
189189
healthServiceName: 'Health',
190190
};

lib/utils/checkPackage.util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const logger = new Logger('PackageLoader');
3232
function optional<T = any>(module: string): T | null {
3333
try {
3434
if (module[0] in { '.': 1 }) {
35-
module = process.cwd() + module.substr(1);
35+
module = process.cwd() + module.substring(1);
3636
}
3737
return require(`${module}`);
3838
} catch (err) {}

package-lock.json

Lines changed: 227 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"delete-empty": "3.0.0",
7171
"eslint": "8.45.0",
7272
"eslint-config-prettier": "8.8.0",
73+
"eslint-plugin-deprecation": "^2.0.0",
7374
"eslint-plugin-import": "2.27.5",
7475
"fastify": "4.20.0",
7576
"gulp": "4.0.2",
@@ -171,14 +172,18 @@
171172
},
172173
"renovate": {
173174
"semanticCommits": true,
174-
"packageRules": [{
175-
"depTypeList": ["devDependencies"],
176-
"automerge": true
177-
}],
175+
"packageRules": [
176+
{
177+
"depTypeList": [
178+
"devDependencies"
179+
],
180+
"automerge": true
181+
}
182+
],
178183
"extends": [
179184
"config:base"
180185
]
181-
},
186+
},
182187
"commitlint": {
183188
"extends": [
184189
"@commitlint/config-angular"
@@ -252,6 +257,7 @@
252257
"@typescript-eslint/eslint-plugin"
253258
],
254259
"extends": [
260+
"plugin:deprecation/recommended",
255261
"plugin:@typescript-eslint/eslint-recommended",
256262
"plugin:@typescript-eslint/recommended",
257263
"prettier"

0 commit comments

Comments
 (0)