Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wiredcraft/health-checks

Package Overview
Dependencies
Maintainers
24
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wiredcraft/health-checks

A generic health checker.

  • 2.2.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
24
Created
Source

@wiredcraft/health-checks

A generic health checker.

Usage

const { HealthChecker, HealthStatus } = require('@wiredcraft/health-checks');
const healthChecker = new HealthChecker();
healthChecker.addCheck(async () => {
    if (Math.random() > 0.5) {
        throw new Error('RandomFailure');
    }
}, 'db', HealthStatus.Unhealthy.name, ['default', 'all']);
healthChecker.addCheck(async () => {
    if (Math.random() > 0.5) {
        throw new Error('RandomFailure');
    }
}, 'external-service', HealthStatus.Degraded.name, ['all']);

// By default, it will filter checks which includes 'default' tag
const res = await healthChecker.getStatus();
// res will be something like 
// {
//     "status": "unhealthy",
//     "checks": [
//         {
//             "name": "db",
//             "state": "unhealthy",
//             "data": {
//                 "reason": "RandomFailure"
//             }
//         }
//     ]
// }

// You can use other tag to filter the checks
const res = await healthChecker.getStatus('all');
// res will be something like 
// {
//     "status": "degraded",
//     "checks": [
//         {
//             "name": "db",
//             "state": "healthy",
//             "data": {
//                 "reason": ""
//             }
//         },
//         {
//             "name": "external-service",
//             "state": "degraded",
//             "data": {
//                 "reason": "RandomFailure"
//             }
//         }
//     ]
// }

For more details, see scenarios in test cases.

Keywords

FAQs

Package last updated on 25 Nov 2020

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc