services-healthcheck
Simple module to check the health status of a service dependencies
Installing
To install it, just use npm:
npm i services-healthcheck
Usage
Parameters
services
:
An object mapping the service name to its URL or to it's URL getter (the service must have a /_ping route), or to a knex connection. Supported DB's: Postgres, MSSQL, MySQL, MariaDB, SQLite3, and Oracle.
const express = ;const knex = ;const healthcheck = default; const getRandomArbitrary = { return Math * max - min + min;}; const getServiceUrl = return `http://service-{getRandomArbitrary(5, 10)}`; const knexInstance = ; const services = 'service-1': 'http://service-1' 'service-2': 'http://service-2' 'service-3': 'http://service-3' 'service-4': 'http://service-4' 'service-5': url: 'http://service-custom-ping' route: '/health/_ping' 'service-x': getServiceUrl 'db-1': knex: knexInstance 'queue-1': queue: host: 'localhost' port: '5672' ; { const app = ; app; return app;}; { const app = await ; app;} ;
After that, it will add a /_health route, that returns the status of the services passed