Skip to content

platform-health

Health check orchestration for NestJS applications built on @nestjs/terminus. Register custom health indicators and expose aggregated health status via a single orchestrator. Extracted from platform-core to provide a focused, independently versionable health module.

Package: @breadstone/archipel-platform-health

npm install @breadstone/archipel-platform-health

Installation

typescript
import {
  HealthModule,
  HealthOrchestrator,
  IHealthIndicator,
  IHealthCheckResult,
  HEALTH_INDICATORS,
} from '@breadstone/archipel-platform-health';

Module Registration

Register the module with one or more health indicators:

typescript
import { Module } from '@nestjs/common';
import { HealthModule } from '@breadstone/archipel-platform-health';
import { DatabaseHealthIndicator } from './health/DatabaseHealthIndicator';
import { RedisHealthIndicator } from './health/RedisHealthIndicator';

@Module({
  imports: [
    HealthModule.withIndicators([DatabaseHealthIndicator, RedisHealthIndicator]),
  ],
})
export class AppModule {}

Implementing a Health Indicator

Each indicator implements the IHealthIndicator interface:

typescript
import { Injectable } from '@nestjs/common';
import type { IHealthIndicator, IHealthCheckResult } from '@breadstone/archipel-platform-health';

@Injectable()
export class DatabaseHealthIndicator implements IHealthIndicator {
  public readonly name = 'database';

  public async isHealthy(): Promise<IHealthCheckResult> {
    try {
      await this._prisma.$queryRaw`SELECT 1`;
      return { status: 'up' };
    } catch (error) {
      return { status: 'down', details: { error: (error as Error).message } };
    }
  }
}

Using the Orchestrator

The HealthOrchestrator runs all registered indicators and returns aggregated results:

typescript
import { Controller, Get } from '@nestjs/common';
import { HealthOrchestrator } from '@breadstone/archipel-platform-health';

@Controller('health')
export class HealthController {
  constructor(private readonly _healthOrchestrator: HealthOrchestrator) {}

  @Get()
  public async check(): Promise<unknown> {
    return this._healthOrchestrator.check();
  }
}

Built-in Consumers

All Archipel platform libraries provide health indicators via their /health subpath export. Register them with HealthModule.withIndicators():

LibraryIndicatorKeyCheck
platform-databaseDatabaseHealthIndicatordatabasePrisma SELECT 1 ping
platform-blob-storageBlobHealthIndicatorblobHTTP ping to blob URL (or disabled if unconfigured)
platform-mailingMailHealthIndicatormailValidates mail host, user, and port config
platform-cachingCachingHealthIndicatorcachingAlways up
platform-queueQueueHealthIndicatorqueueAlways up
platform-paymentsPaymentHealthIndicatorpaymentup if PaymentClientPort injected, else disabled
platform-esigningEsigningHealthIndicatoresigningup if EsigningClientPort injected, else disabled
platform-intelligenceIntelligenceHealthIndicatorintelligenceup if IntelligenceCapabilityRegistry injected, else disabled
platform-analyticsAnalyticsHealthIndicatoranalyticsup if AnalyticsClientPort injected, else disabled
platform-telemetryTelemetryHealthIndicatortelemetryup if OtelSdkHolder injected, else disabled
platform-authenticationAuthenticationHealthIndicatorauthenticationAlways up
platform-mcpMcpHealthIndicatormcpup if McpRegistryService injected, else disabled

See the Health Indicators guide for full setup instructions.


Interfaces

InterfaceDescription
IHealthIndicatorContract for health check implementations (name + isHealthy)
IHealthCheckResultResult object with status ('up' or 'down') and optional details

Tokens

TokenDescription
HEALTH_INDICATORSMulti-provider token for registering health indicators

Resource Bounds

The HealthOrchestrator enforces a maximum of 100 registered indicators. If the limit is exceeded, the indicator is skipped and a warning is logged.


API Reference

The auto-generated API reference is published when API docs are generated for this package.

Released under the MIT License.