function HealthPlugin
Since 0.2.0
HealthPlugin(options?: HealthPluginOptions): IPlugin

Creates a health plugin.

Examples

Example 1

app.register(HealthPlugin());

// Or with custom options
app.register(HealthPlugin({
  endpoints: {
    health: '/health',
    live: '/live',
    ready: '/ready',
  },
  indicators: [
    createHttpIndicator('external-api', { url: 'https://api.example.com/health' }),
    (services) => createDatabaseIndicator(services),
  ],
}));

indicators accepts an instance or a RegistryFactory ((services: IServiceRegistry) => IHealthIndicator). A factory is resolved at onInit — the first phase at which the registry holds every capability — and, because HealthPlugin registers at priority 100, before the database and every other ordinary capability plugin. Instance indicators keep their register() timing.

Parameters

optional
options: HealthPluginOptions

Plugin configuration options

Return Type

IPlugin

A plugin that registers an IHealthService under 'health'

Usage

import { HealthPlugin } from "health-plugin/src/index.ts";