cmm-healthcheck
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Cmm Health Check

Usage

Code

const mongoose = require('mongoose')
const { healthCheck, HealthTypes } = require('cmm-healthcheck')
const Redis = require('ioredis')
const redis = new Redis('REDIS_PORT', 'REDIS_HOST')

healthCheck({
    logger: this.logger,
    integrations: [
       {
        type: HealthTypes.Web,
        name: 'my web api integration',
        host: 'http://validurl.com/healthcheck',
        params: {
          access_token: 'token'
        }
      },
      {
        type: HealthTypes.Mongo,
        mongoose
      },
      {
        type: HealthTypes.Axios,
        name: 'my axios client',
        axiosClient: this.axiosClient,
        host: '/accounts'
      },
      {
        type: HealthTypes.Redis,
        name: 'redis',
        redis,
      },
     
      {
        type: HealthTypes.Rabbitmq,
        name: 'rabbitmq',
        host: 'amqp://host:host@rabbitmq',
        critical: false
      }
    ]
  })
 .then(function(result){
    console.log(result); 
    /* 
     {
      "uptime": 750.86376575,
      "healthy": true,
      "services": [{
          name: 'my web api integration',
          "healthy": true,
          "response_time": 1.86,
          "url": "http://validurl.com/healthcheck",
          "critical": true
        },
        {
          "name": "mongo",
          "healthy": true,
          "critical": true
        },
        {
          "name": "my web axios integration",
          "healthy": true,
          "response_time": 0.652,
          "url": "/accounts",
          "critical": true
        },
        {
          "name": "redis",
          "healthy": true,
          "critical": true
        },
        {
          "name": "rabbitmq",
          "healthy": false,
          "error": {
            "errno": -111,
            "code": "ECONNREFUSED",
          },
          "critical": false
        }
      ]
    }
    */
 })

Package Sidebar

Install

npm i cmm-healthcheck

Weekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

58.2 kB

Total Files

52

Last publish

Collaborators

  • matheus.campos
  • hecbale
  • alvarenga04
  • adilson.feitoza