Skip to content

Commit

Permalink
refactor: remove deprecated Terminus API
Browse files Browse the repository at this point in the history
BREAKING CHANGE: TerminusModule.forRoot{Async) has been removed

In order to migrate, check out: https://docs.nestjs.com/migration-guide#terminus
  • Loading branch information
BrunnerLivio committed Aug 27, 2021
1 parent 5c5ffb1 commit 70e36ed
Show file tree
Hide file tree
Showing 13 changed files with 158 additions and 2,537 deletions.
45 changes: 1 addition & 44 deletions lib/health-check/health-check-executor.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Test } from '@nestjs/testing';
import { HealthCheckExecutor } from './health-check-executor.service';
import { HealthIndicatorResult } from '../health-indicator';
import { HealthCheckResult } from './health-check-result.interface';
import { HealthCheckError } from '@godaddy/terminus';
import { HealthCheckError } from '../health-check/health-check.error';

const healthyCheck = async (): Promise<HealthIndicatorResult> => {
return {
Expand Down Expand Up @@ -98,47 +98,4 @@ describe('HealthCheckExecutorService', () => {
});
});
});

describe('executeDeprecated', () => {
it('should return a result object without errors', async () => {
const result = await healthCheckExecutor.executeDeprecated([
() => healthyCheck(),
]);
expect(result).toEqual<HealthIndicatorResult>({
healthy: {
status: 'up',
},
});
});

it('should return a result object with errors', async () => {
try {
await healthCheckExecutor.executeDeprecated([() => unhealthyCheck()]);
} catch (error) {
expect(error.causes).toEqual<HealthIndicatorResult>({
unhealthy: {
status: 'down',
},
});
}
});

it('should return a result object with mixed errors', async () => {
try {
await healthCheckExecutor.executeDeprecated([
() => healthyCheck(),
() => unhealthyCheck(),
]);
} catch (error) {
expect(error.causes).toEqual<HealthIndicatorResult>({
healthy: {
status: 'up',
},
unhealthy: {
status: 'down',
},
});
}
});
});
});
27 changes: 0 additions & 27 deletions lib/health-check/health-check-executor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,6 @@ import {
export class HealthCheckExecutor implements BeforeApplicationShutdown {
private isShuttingDown = false;

/**
* Executes the given health indicators.
* Implementation for v6 compatibility.
*
* @throws {Error} All errors which are not inherited by the `HealthCheckError`-class
*
* @deprecated
* @returns the result of given health indicators
* @param healthIndicators The health indicators which should get executed
*/
async executeDeprecated(
healthIndicators: HealthIndicatorFunction[],
): Promise<HealthIndicatorResult> {
const { results, errors } = await this.executeHealthIndicators(
healthIndicators,
);
const infoErrorCombined = results.concat(errors);

const details = this.getSummary(infoErrorCombined);

if (errors.length) {
throw new HealthCheckError('Healthcheck failed', details);
} else {
return details;
}
}

/**
* Executes the given health indicators.
* Implementation for v6 compatibility.
Expand Down
132 changes: 0 additions & 132 deletions lib/health-indicator/dns/dns.health.ts

This file was deleted.

1 change: 0 additions & 1 deletion lib/health-indicator/dns/index.ts

This file was deleted.

4 changes: 1 addition & 3 deletions lib/health-indicator/health-indicators.provider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Type, Provider } from '@nestjs/common';
import { Type } from '@nestjs/common';

import {
TypeOrmHealthIndicator,
Expand All @@ -11,7 +11,6 @@ import {
HealthIndicator,
GRPCHealthIndicator,
} from '.';
import { DNSHealthIndicator } from './dns';

/**
* All the health indicators terminus provides as array
Expand All @@ -25,5 +24,4 @@ export const HEALTH_INDICATORS: Type<HealthIndicator>[] = [
MemoryHealthIndicator,
MicroserviceHealthIndicator,
GRPCHealthIndicator,
DNSHealthIndicator,
];
1 change: 0 additions & 1 deletion lib/health-indicator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export * from './health-indicator-result.interface';
export * from './health-indicator';

/** Health Indicators */
export * from './dns/dns.health';
export * from './http/http.health';
export * from './database/mongoose.health';
export * from './database/typeorm.health';
Expand Down

0 comments on commit 70e36ed

Please sign in to comment.