@lokalise/fastify-extras
Version:
Opinionated set of fastify plugins, commonly used in Lokalise
20 lines (19 loc) • 806 B
TypeScript
import type { FastifyPluginCallback } from 'fastify';
import type { CommonFastifyInstance } from '../pluginsCommon.js';
import type { HealthChecker } from './healthcheckCommons.js';
export interface HealthcheckMetricsPluginOptions {
healthChecks: readonly PrometheusHealthCheck[];
}
export type HealthcheckResult = {
checkTimeInMsecs: number;
checkPassed: boolean;
};
export type PrometheusHealthCheck = {
name: string;
checker: (app: CommonFastifyInstance) => Promise<HealthcheckResult>;
};
/**
* Execute healthcheck and calculate the check time
*/
export declare const wrapHealthCheckForPrometheus: (healthCheck: HealthChecker, healthcheckName: string) => PrometheusHealthCheck;
export declare const healthcheckMetricsPlugin: FastifyPluginCallback<HealthcheckMetricsPluginOptions>;