Skip to content

Commit

Permalink
feat(): upgrade to v8
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Upgrade to NestJS v8.x.x
  • Loading branch information
Tony133 authored and BrunnerLivio committed Aug 27, 2021
1 parent 6dd469a commit ba6eee0
Show file tree
Hide file tree
Showing 12 changed files with 3,525 additions and 9,500 deletions.
2 changes: 1 addition & 1 deletion lib/health-check/health-check.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { HealthCheckResult } from './health-check-result.interface';
export class HealthCheckService {
constructor(private healthCheckExecutor: HealthCheckExecutor) {}

private readonly logger = new Logger(HealthCheckService.name, true);
private readonly logger = new Logger(HealthCheckService.name);

/**
* Logs an error message of terminus
Expand Down
2 changes: 1 addition & 1 deletion lib/health-indicator/database/typeorm.health.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class TypeOrmHealthIndicator extends HealthIndicator {
}

private async checkMongoDBConnection(connection: any) {
return new Promise((resolve, reject) => {
return new Promise<void>((resolve, reject) => {
const driver = connection.driver as any;
// Hacky workaround which uses the native MongoClient
driver.mongodb.MongoClient.connect(
Expand Down
13 changes: 8 additions & 5 deletions lib/health-indicator/dns/dns.health.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Injectable, HttpService, Scope } from '@nestjs/common';
import { Injectable, Scope } from '@nestjs/common';
import { HttpService } from '@nestjs/axios';
import { AxiosResponse, AxiosRequestConfig, AxiosError } from 'axios';
import { HealthIndicator, HealthIndicatorResult } from '../';
import { HealthCheckError } from '../../health-check/health-check.error';
import * as deprecate from 'deprecate';
import { lastValueFrom } from 'rxjs';

/**
* The DNSHealthIndicator contains health indicators
Expand Down Expand Up @@ -100,11 +102,12 @@ export class DNSHealthIndicator extends HealthIndicator {
options: AxiosRequestConfig = {},
): Promise<HealthIndicatorResult> {
try {
const response = await this.httpService
.request({ url: url.toString(), ...options })
.toPromise();
const response = lastValueFrom(
this.httpService
.request({ url: url.toString(), ...options }),
);

const isHealthy = await callback(response);
const isHealthy = await callback(await response);

if (!isHealthy) {
throw new HealthCheckError(
Expand Down
2 changes: 1 addition & 1 deletion lib/health-indicator/http/http.health.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Test } from '@nestjs/testing';
import { HealthCheckError } from '../../health-check/health-check.error';
import { HttpService } from '@nestjs/common';
import { HttpService } from '@nestjs/axios';
import { EMPTY, of, throwError } from 'rxjs';
import { AxiosResponse, AxiosRequestConfig, AxiosError } from 'axios';
import { HttpHealthIndicator } from './http.health';
Expand Down
10 changes: 6 additions & 4 deletions lib/health-indicator/http/http.health.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Injectable, HttpService } from '@nestjs/common';
import { Injectable } from '@nestjs/common';
import { HttpService } from '@nestjs/axios';
import { AxiosResponse, AxiosRequestConfig, AxiosError } from 'axios';
import { HealthIndicator, HealthIndicatorResult } from '..';
import { HealthCheckError } from '../../health-check/health-check.error';
import { lastValueFrom } from 'rxjs';

/**
* The HTTPHealthIndicator contains health indicators
Expand Down Expand Up @@ -94,11 +96,11 @@ export class HttpHealthIndicator extends HealthIndicator {
const httpService = httpClient || this.httpService;

try {
const response = await httpService
const response = lastValueFrom(httpService
.request({ url: url.toString(), ...options })
.toPromise();
);

const isHealthy = await callback(response);
const isHealthy = await callback(await response);

if (!isHealthy) {
throw new HealthCheckError(
Expand Down
1 change: 0 additions & 1 deletion lib/health-indicator/memory/memory.health.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Injectable } from '@nestjs/common';

import { HealthIndicator, HealthIndicatorResult } from '../';
import { STORAGE_EXCEEDED } from '../../errors/messages.constant';
import { StorageExceededError } from '../../errors';
Expand Down
2 changes: 1 addition & 1 deletion lib/terminus-bootstrap.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class TerminusBootstrapService implements OnApplicationBootstrap {
/**
* The NestJS logger
*/
private readonly logger = new Logger(TerminusBootstrapService.name, true);
private readonly logger = new Logger(TerminusBootstrapService.name);

constructor(
@Inject(TERMINUS_MODULE_OPTIONS)
Expand Down
2 changes: 1 addition & 1 deletion lib/terminus-core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {
Global,
Module,
Provider,
HttpModule,
Type,
} from '@nestjs/common';
import { HttpModule } from '@nestjs/axios';
import {
TerminusModuleOptions,
TerminusModuleAsyncOptions,
Expand Down
1 change: 0 additions & 1 deletion lib/terminus-lib.provider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { TERMINUS_LIB } from './terminus.constants';
import { Provider } from '@nestjs/common';
import { checkPackages } from './utils';

/**
Expand Down
3 changes: 2 additions & 1 deletion lib/terminus.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DynamicModule, Module, HttpModule } from '@nestjs/common';
import { DynamicModule, Module } from '@nestjs/common';
import { HttpModule } from '@nestjs/axios';
import {
TerminusModuleOptions,
TerminusModuleAsyncOptions,
Expand Down

0 comments on commit ba6eee0

Please sign in to comment.