Socket
Book a DemoInstallSign in
Socket

@qrvey/health-checker

Package Overview
Dependencies
Maintainers
14
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@qrvey/health-checker

![install size](https://packagephobia.com/badge?p=@qrvey/health-checker) ![coverage](https://img.shields.io/badge/unit_test_coverage-87%25-brightgreen)

1.1.1
latest
npmnpm
Version published
Weekly downloads
2K
6.92%
Maintainers
14
Weekly downloads
 
Created
Source

@qrvey/health-checker

install size coverage

An health check library for validating the availability of core service dependencies like Redis, PostgreSQL, and RabbitMQ.

Installation

npm install @qrvey/health-checker

Or with yarn:

yarn add @qrvey/health-checker

Supported Health Check Types

ServiceDependency Key
PostgreSQLdatabase
Rediscache
RabbitMQeventBroker

Usage

const {
  HealthCheckService,
} = require('@qrvey/health-checker');


HealthCheckService.check(['cache', 'database', 'eventBroker']).then((result) => {
  console.log(result);
  /*
  {
    status: 'OK',
    details: {
      cache: 'OK',
      database: 'OK',
      eventBroker: 'OK'
    }
  }
  */
});

You can also check specific dependencies only:

HealthCheckService.check(['cache']).then((result) => {
  console.log(result);
  /*
  {
    status: 'OK',
    details: {
      cache: 'OK'
    }
  }
  */
});

Usage with Fastify

You can expose the health check as a simple route in your Fastify app.

Basic Example: health.routes.js

const {
  HealthCheckService,
} = require('@qrvey/health-checker');
const Fastify = require('fastify');

async function healthRoutes(fastify, _options) {
  fastify.get('/health', async (_request, reply) => {
    const dependencies = ['database', 'eventBroker'];
    const result = await HealthCheckService.check(dependencies);
    const httpStatus = result.status === "FAILED" ? 503 : 200;
    return reply.code(httpStatus).send(result);
  });
}

const app = Fastify({ logger: true });
app.register(healthRoutes);
app.listen({ port: 3000 });

Basic Example Output

GET /health

{
  "status": "OK",
  "details": {
    "database": "OK",
    "eventBroker": "OK"
  }
}

Validating Queue Subscriptions (Optional)

If you want to explicitly validate that your service is subscribed to one or more RabbitMQ queues, you can pass an additional params object to the check method.

fastify.get('/health', async (_request, reply) => {
  const dependencies = ['eventBroker'];
  const params = {
    eventBroker: {
      queues: ['queue_name_1', 'queue_name_2'], // these must match the configured subscriptions
    },
  }

  const result = await HealthCheckService.check(dependencies, params);
  const httpStatus = result.status === "FAILED" ? 503 : 200;
  return reply.code(httpStatus).send(result);
});

Sample output

GET /health

{
  "status": "OK",
  "details": {
    "eventBroker": "OK"
  }
}

Keywords

health

FAQs

Package last updated on 30 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.