{"id":13393049,"url":"https://github.com/gritzkoo/nodejs-health-checker","last_synced_at":"2025-08-22T00:31:08.127Z","repository":{"id":38453888,"uuid":"295996034","full_name":"gritzkoo/nodejs-health-checker","owner":"gritzkoo","description":"This is a Node package that allows you to track the health of your application providing readiness and liveness functionalities.","archived":false,"fork":false,"pushed_at":"2024-04-24T15:25:30.000Z","size":1391,"stargazers_count":43,"open_issues_count":0,"forks_count":12,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-01T15:28:48.335Z","etag":null,"topics":["hacktoberfest","hacktoberfest2020","health-check","healthcheck","k8s","liveness-probe","node-typescript","nodejs","nodemodule","npm-package","readiness-probe","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/nodejs-health-checker","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gritzkoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-16T10:10:50.000Z","updated_at":"2024-05-31T18:00:31.902Z","dependencies_parsed_at":"2023-12-13T13:38:27.690Z","dependency_job_id":"5706bfc4-9e58-4e76-bc1c-290a7b7ca15d","html_url":"https://github.com/gritzkoo/nodejs-health-checker","commit_stats":{"total_commits":47,"total_committers":9,"mean_commits":5.222222222222222,"dds":0.574468085106383,"last_synced_commit":"8e3d6a1583e15f3806ae1d4452863607ef8eb686"},"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gritzkoo%2Fnodejs-health-checker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gritzkoo%2Fnodejs-health-checker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gritzkoo%2Fnodejs-health-checker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gritzkoo%2Fnodejs-health-checker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gritzkoo","download_url":"https://codeload.github.com/gritzkoo/nodejs-health-checker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230542288,"owners_count":18242332,"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":["hacktoberfest","hacktoberfest2020","health-check","healthcheck","k8s","liveness-probe","node-typescript","nodejs","nodemodule","npm-package","readiness-probe","typescript"],"created_at":"2024-07-30T17:00:41.693Z","updated_at":"2024-12-20T06:06:28.773Z","avatar_url":"https://github.com/gritzkoo.png","language":"TypeScript","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# nodejs-health-checker\n\n\u003cdiv align=\"center\"\u003e\n\n![npm](https://img.shields.io/npm/dt/nodejs-health-checker?style=for-the-badge)\u003cbr\u003e\n[![npm version](https://badge.fury.io/js/nodejs-health-checker.svg)](https://badge.fury.io/js/nodejs-health-checker)\n![test](https://github.com/gritzkoo/nodejs-health-checker/workflows/test/badge.svg?branch=master)\n[![Coverage Status](https://coveralls.io/repos/github/gritzkoo/nodejs-health-checker/badge.svg?branch=master)](https://coveralls.io/github/gritzkoo/nodejs-health-checker?branch=master)\n[![License Status](https://img.shields.io/github/license/gritzkoo/nodejs-health-checker)](https://img.shields.io/github/license/gritzkoo/nodejs-health-checker)\n[![Issues Status](https://img.shields.io/github/issues/gritzkoo/nodejs-health-checker)](https://img.shields.io/github/issues/gritzkoo/nodejs-health-checker)\n[![Tag Status](https://img.shields.io/github/v/tag/gritzkoo/nodejs-health-checker)](https://img.shields.io/github/v/tag/gritzkoo/nodejs-health-checker)\n[![Languages Status](https://img.shields.io/github/languages/count/gritzkoo/nodejs-health-checker)](https://img.shields.io/github/languages/count/gritzkoo/nodejs-health-checker)\n[![Repo Size Status](https://img.shields.io/github/repo-size/gritzkoo/nodejs-health-checker)](https://img.shields.io/github/repo-size/gritzkoo/nodejs-health-checker)\n\u003c/div\u003e\n\n___\n\n## Contributors\n\n![contributors](https://contrib.rocks/image?repo=gritzkoo/nodejs-health-checker)\n\n\u003eMade with [contributors-img](https://contrib.rocks).\n___\n\nThis is a Node package that allows you to track the health of your application, providing two ways of checking:\n\n*__Simple__*: will respond to a JSON as below and that allows you to check if your application is online and responding without checking any kind of integration.\n\n```json\n{\n  \"status\": \"fully functional\"\n}\n```\n\n*__Detailed__*: will respond a JSON as below and that allows you to check if your application is up and running and check if all of your integrations informed in the configuration list is up and running.\n\n```json\n{\n    \"name\": \"My node application\",\n    \"version\": \"my version\",\n    \"status\": true,\n    \"date\": \"2020-09-18T15:29:41.616Z\",\n    \"duration\": 0.523,\n    \"integrations\": [\n        {\n            \"name\": \"redis integration\",\n            \"kind\": \"Redis DB integration\",\n            \"status\": true,\n            \"response_time\": 0.044,\n            \"url\": \"redis:6379\"\n        },\n        {\n            \"name\": \"My memcache integration\",\n            \"kind\": \"Memcached integraton\",\n            \"status\": true,\n            \"response_time\": 0.038,\n            \"url\": \"memcache:11211\"\n        },\n        {\n            \"name\": \"my web api integration\",\n            \"kind\": \"Web integrated API\",\n            \"status\": true,\n            \"response_time\": 0.511,\n            \"url\": \"https://github.com/status\"\n        },\n        {\n            \"name\": \"my dynamo\",\n            \"kind\": \"AWS Dynamo DB\",\n            \"status\": true,\n            \"response_time\": 0.004,\n            \"url\": \"http://localhost:8000\",\n        }\n    ]\n}\n```\n\n## How to install\n\n```sh\nnpm i nodejs-health-checker\n```\n\n## Available integrations\n\n- [x] Redis\n- [x] Memcached\n- [x] Web integration (https)\n- [x] AWS DynamoDB\n- [x] Sequelize (authored by @MikeG96)\n- [x] Custom integration support (authored by @youngpayters)\n\n## How to use\n\nExample using Nodejs + Express\n\n```javascript\nimport express from \"express\";\nimport {\n  HealthcheckerDetailedCheck,\n  HealthcheckerSimpleCheck\n} from \"./healthchecker/healthchecker\";\nimport { Dialects, HealthTypes } from \"./interfaces/types\";\n\nconst server = express();\n\nserver.get(\"/health-check/liveness\", (_, res) =\u003e {\n  res.send(HealthcheckerSimpleCheck());\n});\n\nserver.get(\"/health-check/readiness\", async (_, res) =\u003e {\n  res.send(\n    await HealthcheckerDetailedCheck({\n      name: \"My node application\",\n      version: \"my version\",\n      // here you will inform all of your external dependencies\n      // that your application must be checked to keep healthy\n      // available integration types: [\n      //   HealthTypes.Redis,\n      //   HealthTypes.Memcached,\n      //   HealthTypes.Web\n      //   HealthTypes.Custom\n      // ]\n      integrations: [\n        {\n          type: HealthTypes.Redis,\n          name: \"redis integration\",\n          host: \"redis\",\n        },\n        {\n          type: HealthTypes.Memcached,\n          name: \"My memcache integration\",\n          host: \"memcache:11211\",\n        },\n        {\n          type: HealthTypes.Web,\n          name: \"my web api integration\",\n          host: \"https://github.com/status\",\n          headers: [{ key: \"Accept\", value: \"application/json\" }],\n        },\n        {\n          type: HealthTypes.Dynamo,\n          name: \"my dynamo\",\n          host: \"http://localhost\",\n          port: 8000,\n          Aws: {\n            region: \"us-east-1\",\n            access_key_id: \"\",\n            secret_access_key: \"\",\n          },\n        },\n        {\n          type: HealthTypes.Database,\n          name: \"my database\",\n          host: \"localhost\",\n          dbPort: 5432,\n          dbName: \"postgres\",\n          dbUser: \"postgres\",\n          dbPwd: \"root\",\n          dbDialect: Dialects.postgres,\n        },\n        {\n          type: HealthTypes.Custom,\n          name: \"my custom integration\",\n          host: \"localhost\",\n          customCheckerFunction: () =\u003e { return { status: true, error: {} }},\n        },\n      ],\n    })\n  );\n});\n\nexport default server;\n```\n\nAnd then, you could call these endpoints manually to see your application health, but, if you are using modern Kubernetes deployment, you can config your chart to check your application with the setup below. There is an [Example](https://runkit.com/gritzkoo/618d325cb041300008eb7bfe) on runkit too.\n\n```yaml\napiVersion: v1\nkind: Pod\nmetadata:\n  labels:\n    test: liveness\n  name: liveness-http\nspec:\n  containers:\n  - name: liveness\n    image: 'node' #your application image\n    args:\n    - /server\n    livenessProbe:\n      httpGet:\n        path: /health-check/liveness\n        port: 80\n        httpHeaders:\n        - name: Custom-Header\n          value: Awesome\n      initialDelaySeconds: 3\n      periodSeconds: 3\n  - name: readiness\n    image: 'node' #your application image\n    args:\n    - /server\n    readinessProbe:\n      httpGet:\n        path: /health-check/readiness\n        port: 80\n        httpHeaders:\n        - name: Custom-Header\n          value: Awesome\n      initialDelaySeconds: 3\n      periodSeconds: 3\n```\n\n### Import using require\n\nIf your application needs to use the `require` instead of ECMAScript, you should import on this way:\n\n```typescript\nconst express = require('express');\nconst {\n    HealthcheckerSimpleCheck,\n    HealthcheckerDetailedCheck\n} = require(\"nodejs-health-checker/dist/healthchecker/healthchecker\");\nconst { HealthTypes } = require(\"nodejs-health-checker/dist/interfaces/types\");\nconst server = express();\nserver.get('/', (req, res) =\u003e {\n    res.json({ status: \"I'm alive!\" });\n})\nserver.get('/health-check/liveness', (req, res) =\u003e {\n    res.json(HealthcheckerSimpleCheck())\n})\nserver.get('/health-check/readiness', async (req, res) =\u003e {\n    let result = await HealthcheckerDetailedCheck({\n        name: 'example',\n        version: 'v1.0.0',\n        integrations: [\n            {\n                type: HealthTypes.Web,\n                name: 'A simple api integration check',\n                host: 'https://github.com/status'\n            }\n        ]\n    });\n    res.json(result);\n})\nserver.listen(3000, () =\u003e {\n    console.log('server started at port 3000')\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgritzkoo%2Fnodejs-health-checker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgritzkoo%2Fnodejs-health-checker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgritzkoo%2Fnodejs-health-checker/lists"}