npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cloudnative/health-connect

v2.1.0

Published

Connect middleware for Cloud Health

Downloads

56,611

Readme

Cloud Health Connect

Cloud Health Connect provides a Connect Middleware for use in Express.js, Loopback and other frameworks that uses Cloud Health to provide:

  • Readiness checks
  • Liveness checks
  • Combined Health (Readiness and Liveness) checks
  • Shutdown handling

to enable applications for use with Kubernetes and Cloud Foundry based clouds.

Using Cloud Health Connect

Cloud Health Connect takes the status reported by Cloud Health and makes it available on the liveness and/or readiness URL endpoints that the middleware is configured to use.

The middleware writes the data returned by the Cloud Health module as JSON, and sets the HTTP Status Code as follows:

| Cloud Health Status | Readiness Status Code | Liveness Status Code | Combined Health Status Code | |---------------------|-----------------------|----------------------|-----------------------------| | STARTING | 503 UNAVAILABLE | 200 OK | 503 UNAVAILABLE | | UP | 200 OK | 200 OK | 200 OK | | DOWN | 503 UNAVAILABLE | 503 UNAVAILABLE | 503 UNAVAILABLE | | STOPPING | 503 UNAVAILABLE | 503 UNAVAILABLE | 503 UNAVAILABLE | | STOPPED | 503 UNAVAILABLE | 503 UNAVAILABLE | 503 UNAVAILABLE | | - | 500 SERVER ERROR | 500 SERVER ERROR | 500 SERVER ERROR |

Using Cloud Health with Node.js

  1. Installation:
npm install @cloudnative/health-connect
  1. Set up a HealthChecker:
const health = require('@cloudnative/health-connect');
let healthcheck = new health.HealthChecker();
  1. Register a separate Liveness endpoint:
app.use('/live', health.LivenessEndpoint(healthcheck))

If no livessness checks are registered, this will report 200 OK and UP.

  1. Register a separate readiness endpoint:
app.use('/ready', health.ReadinessEndpoint(healthcheck))

If no readiness checks are registered, this will report 200 OK and UP.

  1. Register a combined health endpoint:
app.use('/health', health.HealthEndpoint(healthcheck))

If no readiness or liveness checks are registered, this will report 200 OK and UP.

For information on how to register startup, readiness, liveness and shutdown checks, see the Cloud Health documentation.

Health, Liveness and Readiness endpoints

The difference between liveness and readiness endpoints is the purpose: readiness should be used to denote whether an application is "ready" to receive requests, and liveness should be used to denote whether an application is "live" (vs. in a state where it should be restarted.

The combined health endpoint is designed for cloud technologies, such as Cloud Foundry which only support a single endpoint for both liveness and readiness checking.

Using Cloud Health Connect with Typescript

The Cloud Health Connect module is created in TypeScript and as such provides out of the box TypeScript support.

Module Long Term Support Policy

This module adopts the Module Long Term Support (LTS) policy, with the following End Of Life (EOL) dates:

| Module Version | Release Date | Minimum EOL | EOL With | Status | |------------------|--------------|-------------|--------------|---------| | 2.x.x | May 2019 | April 2021 | | Current | | 1.x.x | July 2018 | Dec 2019 | | LTS |

License

Apache-2.0