UNPKG

@visulima/health-check

Version:

A library built to provide support for defining service health for node services. It allows you to register async health checks for your dependencies and the service itself, provides a health endpoint that exposes their status, and health metrics.

14 lines (10 loc) 534 B
'use strict'; const httpStatusCodes = require('http-status-codes'); var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); const readyhandler = /* @__PURE__ */ __name((healthCheck) => async (_request, response) => { const { healthy } = await healthCheck.getReport(); response.statusCode = healthy ? httpStatusCodes.StatusCodes.NO_CONTENT : httpStatusCodes.StatusCodes.SERVICE_UNAVAILABLE; response.end(); }, "default"); module.exports = readyhandler;