# nodejs-health-service

> A simple package to check health for your nodeJs applications.

Latest version **1.0.2** (published 2021-05-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install nodejs-health-service
pnpm add nodejs-health-service
yarn add nodejs-health-service
bun add nodejs-health-service
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-05-17 |
| First published | 2021-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 12.1 KB |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Archit Gupta |
| Maintainers | archy_95 |
| Keywords | nodejs, health-check, redis, mongodb |

## Links

- npm: https://www.npmjs.com/package/nodejs-health-service
- Repository: https://github.com/arch1995/node-health-check
- Homepage: https://github.com/arch1995/node-health-check#readme
- Issues: https://github.com/arch1995/node-health-check/issues
- npm.io page: https://npm.io/package/nodejs-health-service

## Dependencies (3)

- [redis](https://npm.io/package/redis.md) ^3.1.2
- [amqplib](https://npm.io/package/amqplib.md) ^0.7.1
- [mongoose](https://npm.io/package/mongoose.md) ^5.12.8

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2021-05-17
- 1.0.1 — 2021-05-17
- 1.0.0 — 2021-05-17

## README

This will help you track the health of your application and different services used.

# Installation

```
  npm i node-health-check
```

# Simple Health Check

Ex:

```
const { SimpleHealthCheck } = require('node-health-check')

routes.route('/_health/status, (_req, res) => {
  res.send(SimpleHealthCheck());
});

```

This check simply returns a JSON object like this

```
{ status: 'ok' }
```

# Detailed Health Check

You can either pass config to the `DetailedHealthCheck` function or create a file named `health-check.js`.

Ex:

```
const {
  DetailedHealthCheck,
  HealthCheckerTypes
} = require('node-health-check')

routes.route('/_health/status, (_req, res) => {
  res.send(
    await DetailedHealthCheck({
      name: "My node application",
      integrations: [
        {
          type: HealthCheckerTypes.Redis,
          serviceName: "redis integration",
          url: "redis://localhost:6379",
        },
        {
          type: HealthCheckerTypes.MongoDb,
          serviceName: "mongodb integration",
          url: "localhost:27017/db",
        },
      ],
    })
  );
});

```

`health-check.js`
```
const { HealthCheckerTypes } = require('./index');

module.exports = {
    name         : 'testing application',
    integrations : [
        {
            type        : HealthCheckerTypes.Redis,
            serviceName : 'redis integration',
            url         : 'redis://localhost:6379',
        },
        {
            type        : HealthCheckerTypes.MongoDb,
            serviceName : 'mongodb integration',
            url         : 'localhost:27017/db',
        },
    ],
};
```

This checks returns a JSON object which allows you to check health & status of integrations your application is using.

```
{
    "name": "My node application",
    "status": true,
    "integrations": [
        {
            "service_name": "redis integration",
            "url": "redis://localhost:6379",
            "status": true,
            "response_time": 0.041,
            "error": null
        },
        {
            "service_name": "mongodb integration",
            "url": "localhost:27017/db",
            "status": true,
            "response_time": 0.641,
            "error": null
        }
    ]
}
```

## Available integrations

- [x] Redis
- [x] Mongodb
- [x] RabbitMQ
- [ ] Web integration (https)

---
_Source: https://npm.io/package/nodejs-health-service · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
