# btrz-health-check

> A series of classes that will ping different service types to verify accessibility.

Latest version **3.4.0** (published 2026-11-25) · MIT license · 474 weekly downloads

## Install

```sh
npm install btrz-health-check
pnpm add btrz-health-check
yarn add btrz-health-check
bun add btrz-health-check
```

## Health

**Score 60/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score; growing popularity.

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

## Facts

| | |
|---|---|
| Version | 3.4.0 |
| Published | 2026-11-25 |
| First published | 2016-01-05 |
| Weekly downloads | 474 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 32.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | hgarcia |
| Maintainers | betterez-support |
| Keywords | Microservices, checks, ping, accesibility, sqs, mongo, http |

## Links

- npm: https://www.npmjs.com/package/btrz-health-check
- Repository: https://github.com/Betterez/btrz-health-check
- Homepage: https://github.com/Betterez/btrz-health-check#readme
- Issues: https://github.com/Betterez/btrz-health-check/issues
- npm.io page: https://npm.io/package/btrz-health-check

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [@temporal-architect/claude-plugin](https://npm.io/package/@temporal-architect/claude-plugin.md) — 335 weekly downloads

## Recent versions

- 3.4.0 (latest) — 2026-11-25
- 3.3.0 — 2026-06-26
- 3.2.0 — 2026-06-16
- 3.1.0 — 2026-04-17
- 3.0.0 — 2023-04-27
- 2.3.0 — 2022-07-27
- 2.2.0 — 2020-05-13
- 2.1.0 — 2020-05-12
- 2.0.0 — 2019-08-14
- 1.7.1 — 2018-10-29
- 1.6.1 — 2016-02-29
- 1.6.0 — 2016-01-07
- 1.5.0 — 2016-01-07
- 1.4.0 — 2016-01-05
- 1.3.1 — 2016-01-05
- … 5 more at https://npm.io/package/btrz-health-check/versions

## README

# btrz-health-check

A series of classes that will ping different service types to verify accessibility. Used in Betterez microservices to check status of dependent services.

## Runtimes supported

io.js >= 2.0.3
node >= v4.2

## Usage

The main class is the `HealthCheckers` class.

This class exposes only one method `.checkStatus()` that takes an array of checkers.
Each checker will check one service and returns a promise that will resolve or reject accordingly to the status of the service.
The module comes with a series of checkers that you can configure and use for your particular case (see below for more information).
You can also create your own checkers easily.

## Custom checkers

All custom providers will return a promise that resolves or fails with the service name and status.

    {name: "ServiceName", status: 200} //if promise resolves
    {name: "ServiceName", status: 200} //if promise rejects

All custom providers also take an optional `options` parameter that allow to override the service name and to provide a logger object.

Override the service name is useful when you need to validate the connection to multiple services of the same type.

    let mongoChecker = new MongoDbHealthChecker(mongoDriver, {name: "MyCustomServiceName"});

You can also provide a logger to log the error on failure. The object should have an `.error` function. It will be called with the name of the service and the error.

    let mongoChecker = new MongoDbHealthChecker(mongoDriver, {logger: myLogger});

## Build in checkers

### SQS

Will check connectivity to Amazon SQS. It will read a list of queues available for the logged in user.

    {name: "SQS", status: 200} //if promise resolves
    {name: "SQS", status: 200} //if promise rejects

    #### Usage

        let SQSHealthChecker =  require("btrz-health-checker").SQSHealthChecker;

        let sqsChecker = new SQSHealthChecker(awsSqsDriver);
        sqsChecker.checkStatus()
          .then(function (result) {
            //If's working fine
          })
          .catch(function (result) {
            //Something is not wright.
          });

The only mandatory parameter is an instance of a properly configured AWS SQS driver.
Internally we will call the `listQueues()` function, so it should at least implement that function.


### MongoDb

Will check connectivity to MongoDb doing a call to collectionNames in the MongoDb driver.

    {name: "MongoDb", status: 200} //if promise resolves
    {name: "MongoDb", status: 200} //if promise rejects

#### Usage

    let MongoDbHealthChecker =  require("btrz-health-checker").MongoDbHealthChecker;

    let mongoChecker = new MongoDbHealthChecker(mongoDriver);
    mongoChecker.checkStatus()
      .then(function (result) {
        //If's working fine
      })
      .catch(function (result) {
        //Something is not wright.
      });

The only mandatory parameter is an instance of a properly configured mongoDriver.
Internally we will call the `collectionNames()` function, so it should at least implement that function.


### Socket

Will check connectivity to a socket server using the `net` module

    {name: "Socket", status: 200} //if promise resolves
    {name: "Socket", status: 200} //if promise rejects

#### Usage

    let SocketHealthChecker =  require("btrz-health-checker").SocketHealthChecker;

    let socketChecker = new SocketHealthChecker(mongoDriver);
    socketChecker.checkStatus()
      .then(function (result) {
        //If's working fine
      })
      .catch(function (result) {
        //Something is not wright.
      });

The only mandatory parameter is a config literal with a host and port to connect to.
The config can also contains a `timeout` property and it will be use to fail in case the timeout is reached, the default value is 5000.

### Sequelize

Will check connectivity to the Sequelize DB doing a call to authenticate.

    {name: "Sequelize DB", status: 200} //if promise resolves
    {name: "Sequelize DB", status: 500} //if promise rejects

#### Usage

    const SequelizeDbHealthChecker =  require("btrz-health-checker").SequelizeDbHealthChecker,
      sequelizeChecker = new SequelizeDbHealthChecker(sequelize);

    sequelizeChecker.checkStatus()
      .then((result) => {
        //working fine
      })
      .catch((result) => {
        //Something is not right.
      });

The only mandatory parameter is an instance of sequelize.
Internally we will call the `authenticate()` function along with a valid sequelize config, so it should at least implement that function with a valid DB config.

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