Skip to content

Commit

Permalink
refactor(terminus): Change unknown to any type
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunnerLivio committed May 15, 2019
1 parent 596b1e2 commit 20bbdac
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 121 deletions.
4 changes: 2 additions & 2 deletions lib/errors/connection-not-found.error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { CONNECTION_NOT_FOUND } from './messages.constant';
export class ConnectionNotFoundError extends HealthCheckError {
/**
* Initializes the error
* @param {unknown} cause The cause of the health check error
* @param {any} cause The cause of the health check error
*/
constructor(cause: unknown) {
constructor(cause: any) {
super(CONNECTION_NOT_FOUND, cause);
}
}
4 changes: 2 additions & 2 deletions lib/errors/storage-exceeded.error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ export class StorageExceededError extends HealthCheckError {
* Initializes the error
*
* @param {string} keyword The keyword (heap, rss, disk e.g.)
* @param {unknown} cause The cause of the health check error
* @param {any} cause The cause of the health check error
*/
constructor(keyword: string, cause: unknown) {
constructor(keyword: string, cause: any) {
super(STORAGE_EXCEEDED(keyword), cause);
}
}
4 changes: 2 additions & 2 deletions lib/errors/timeout-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export class TimeoutError extends HealthCheckError {
/**
* Initializes the error
* @param {number} timeout The given timeout in ms
* @param {unknown} cause The cause of the health check error
* @param {any} cause The cause of the health check error
*/
constructor(timeout: number, cause: unknown) {
constructor(timeout: number, cause: any) {
super(TIMEOUT_EXCEEDED(timeout), cause);
}
}
2 changes: 1 addition & 1 deletion lib/health-indicators/dns/dns.health.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class DNSHealthIndicator extends HealthIndicator {
private async pingDNS(
url: string,
options: AxiosRequestConfig,
): Promise<AxiosResponse<unknown> | unknown> {
): Promise<AxiosResponse<any> | any> {
return await this.httpService.request({ url, ...options }).toPromise();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/health-indicators/health-indicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export abstract class HealthIndicator {
protected getStatus(
key: string,
isHealthy: boolean,
data?: { [key: string]: unknown },
data?: { [key: string]: any },
): HealthIndicatorResult {
return {
[key]: {
Expand Down
2 changes: 1 addition & 1 deletion lib/interfaces/health-indicator.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type HealthIndicatorResult = {
/**
* Optional settings of the health indicator result
*/
[optionalKeys: string]: unknown;
[optionalKeys: string]: any;
};
};

Expand Down
4 changes: 2 additions & 2 deletions lib/interfaces/terminus-module-options.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ export interface TerminusModuleAsyncOptions
* The factory which should be used to provide the Terminus options
*/
useFactory?: (
...args: unknown[]
...args: any[]
) => Promise<TerminusModuleOptions> | TerminusModuleOptions;
/**
* The providers which should get injected
*/
inject?: unknown[];
inject?: any[];
}
12 changes: 6 additions & 6 deletions lib/terminus-bootstrap.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,23 @@ export class TerminusBootstrapService implements OnApplicationBootstrap {
*/
private async executeHealthIndicators(
healthIndicators: HealthIndicatorFunction[],
): Promise<{ results: unknown[]; errors: unknown[] }> {
const results: unknown[] = [];
const errors: unknown[] = [];
): Promise<{ results: any[]; errors: any[] }> {
const results: any[] = [];
const errors: any[] = [];
await Promise.all(
healthIndicators
// Register all promises
.map(healthIndicator => healthIndicator())
.map((p: Promise<unknown>) =>
.map((p: Promise<any>) =>
p.catch((error: any) => {
// Is not an expected error. Throw further!
if (!error.causes) throw error;
// Is a expected health check error
errors.push((error as HealthCheckError).causes);
}),
)
.map((p: Promise<unknown>) =>
p.then((result: unknown) => result && results.push(result)),
.map((p: Promise<any>) =>
p.then((result: any) => result && results.push(result)),
),
);

Expand Down
6 changes: 3 additions & 3 deletions lib/utils/promise-timeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ export class TimeoutError extends Error {}
* raise a TimeoutError
*
* @param {number} ms The timeout in milliseconds
* @param {Promise<unknown>} promise The promise which should get executed
* @param {Promise<any>} promise The promise which should get executed
*
* @internal
*/
export const promiseTimeout = function(
ms: number,
promise: Promise<unknown>,
): Promise<unknown> {
promise: Promise<any>,
): Promise<any> {
// Create a promise that rejects in <ms> milliseconds
let timeout = new Promise((_, reject) => {
let id = setTimeout(() => {
Expand Down
Loading

0 comments on commit 20bbdac

Please sign in to comment.