{"id":18389694,"url":"https://github.com/danielwpz/health-check","last_synced_at":"2025-04-12T06:30:04.832Z","repository":{"id":57105697,"uuid":"170374996","full_name":"danielwpz/health-check","owner":"danielwpz","description":"Health check utils for Nodejs","archived":false,"fork":false,"pushed_at":"2019-02-12T19:25:18.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-17T05:38:41.815Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielwpz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-12T19:07:55.000Z","updated_at":"2019-02-12T19:25:19.000Z","dependencies_parsed_at":"2022-08-21T01:00:50.590Z","dependency_job_id":null,"html_url":"https://github.com/danielwpz/health-check","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielwpz%2Fhealth-check","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielwpz%2Fhealth-check/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielwpz%2Fhealth-check/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielwpz%2Fhealth-check/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielwpz","download_url":"https://codeload.github.com/danielwpz/health-check/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248528887,"owners_count":21119396,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T01:44:11.659Z","updated_at":"2025-04-12T06:30:04.806Z","avatar_url":"https://github.com/danielwpz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# health-check\nA promise-based health check util for Nodejs\n\n## Install\n`npm i @danielwpz/health-check`\n\n## Example\n```\nconst Healthcheck = require('@danielwpz/health-check');\nconst Checker = Healthcheck.Checker;\nconst HTTPChecker = Healthcheck.HTTPChecker;\n\nconst okChecker = new Checker('ok', () =\u003e Promise.resolve(true), 100);\nconst throwChecker = new Checker('throw', () =\u003e Promise.reject('Bad happened'), 100);\nconst timeoutChecker = new Checker('timeout', () =\u003e new Promise((res, rej) =\u003e {}), 1000);\nconst httpChecker = new HTTPChecker('google', 'https://www.google.com/');\n\nconst healthcheck = new Healthcheck([okChecker, throwChecker, timeoutChecker, httpChecker]);\nhealthcheck.run().then(console.log);\n```\n\nshould print\n\n```\n[ { name: 'ok', healthy: true, critical: false, time: 32 },\n  { name: 'throw', healthy: false, critical: false, time: 30 },\n  { name: 'timeout', healthy: false, critical: false, time: 1004 },\n  { name: 'google', healthy: true, critical: false, time: 169 },\n  { name: '404', healthy: false, critical: false, time: 421 } ]\n```\n\n## API\n- `Healthcheck`\n    - `constructor([Healthcheck.Checker...])`\n    - `run(): Promise`\n\n- `Chekcer`\n    - `constructor(name, promiseFn, timeout, critical)`\n        - `name`: The name for this health checker\n        - `promiseFn`: A function that returns a `Promise`, which will be called each time when the checkers runs\n        - `timeout`: Timeout in ms\n        - `critical`: An indicator of whether this is a critical health check. Currently not used\n    - `check(): Promise`\n    \n- `HTTPChecker extends Checker`\n    - `constructor(name, url, timeout, critical)`\n        - `url`: The URL to `GET`. Only 2xx responses are considered healthy.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielwpz%2Fhealth-check","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielwpz%2Fhealth-check","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielwpz%2Fhealth-check/lists"}