Skip to content

Commit

Permalink
chore: update jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunnerLivio committed Jan 25, 2025
1 parent f9252d1 commit 15ec9d0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
4 changes: 3 additions & 1 deletion lib/health-check/health-check.error.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/**
* @deprecated
* This class has been deprecated and will be removed in the next major release.
* **This class has been deprecated and will be removed in the next major release.**
* Instead utilise the `HealthIndicatorService` to indicate the health of your health indicator.
*
* @see {@link https://docs.nestjs.com/migration-guide#terminus-module|Migration Guide}
*/
export class HealthCheckError extends Error {
causes: any;
Expand Down
13 changes: 11 additions & 2 deletions lib/health-indicator/health-indicator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,23 @@ import { type HealthIndicatorResult } from './health-indicator-result.interface'
*/
@Injectable()
export class HealthIndicatorService {
check<Key extends string>(key: Key) {
check<const Key extends string>(key: Key) {
return new HealthIndicatorSession(key);
}
}

type AdditionalData = Record<string, unknown>;

/**
* Indicate the health of a health indicator with the given key
*
* @publicApi
*/
export class HealthIndicatorSession<Key extends Readonly<string> = string> {
constructor(private readonly key: Key) {}

/**
* Mark the health indicator as down
* Mark the health indicator as `down`
* @param data additional data which will get appended to the result object
*/
down<T extends AdditionalData>(
Expand Down Expand Up @@ -49,6 +54,10 @@ export class HealthIndicatorSession<Key extends Readonly<string> = string> {
} as Record<Key, typeof detail>;
}

/**
* Mark the health indicator as `up`
* @param data additional data which will get appended to the result object
*/
up<T extends AdditionalData>(data?: T): HealthIndicatorResult<Key, 'up', T>;
up<T extends string>(
data?: T,
Expand Down
13 changes: 8 additions & 5 deletions lib/health-indicator/health-indicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@ export type HealthIndicatorFunction = () =>
| HealthIndicatorResult;

/**
* @deprecated
* **This class has been deprecated and will be removed in the next major release.**
* Instead utilise the `HealthIndicatorService` to indicate the health of your health indicator.
*
* @see {@link https://docs.nestjs.com/migration-guide#terminus-module|Migration Guide}
*
* @description
* Represents an abstract health indicator
* with common functionalities
*
* A custom HealthIndicator should inherit the `HealthIndicator` class.
*
* @example
* ```typescript
*
* class MyHealthIndicator extends HealthIndicator {
* public check(key: string) {
* // Replace with the actual check
Expand All @@ -26,11 +33,7 @@ export type HealthIndicatorFunction = () =>
* }
* }
* ```
*
* @publicApi
* @deprecated
* This class has been deprecated and will be removed in the next major release.
* Instead utilise the `HealthIndicatorService` to indicate the health of your health indicator.
*/
export abstract class HealthIndicator {
/**
Expand Down

0 comments on commit 15ec9d0

Please sign in to comment.