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

hapi-health-check

v1.1.0

Published

Add new route that can be used as a heath check for the application and the backends

Downloads

1

Readme

= hapi-health-check

A https://github.com/hapijs/hapi[hapi] plugin used to add a health check to a server.

Internally it is using the library https://github.com/atomantic/hapi-and-healthy[hapi-and-healthy].

== Requirements

  • nodejs >= 4
  • npm >= 2

== Install

[source,shell] .Add the dependency to your package.json

npm install hapi-health-check --save

== Usage === Importing the lib

[source,javascript] .Require the lib if using ES5

var hapiHealthCheck = require('hapi-health-check');

[source,javascript] .Import the module if using ES6

import hapiHealthCheck from 'hapi-health-check'

=== Using the lib

[source,javascript] .Register the plugin in your Hapi server (ES6 syntax)

import hapiHealthcheck from 'hapi-health-check'

Server.register({ register: hapiHealthcheck, // options are explained below. Options are not mandatory. Default values are the one used in this snippet. options: { path: '/status', health_checks: [{}], custom_health_checks: [], feature_health_checks: [{}], custom_feature_health_checks: [], } }, (err) => { // handle error })

[source,javascript] .Use built-in healthchecks

Server.register({ register: hapiHealthcheck, options: { path: '/status', // you can choose among all these built-in health checks health_checks: [ { type: 'postgres', options: { url: 'POSTGRES_URL', ssl: false // default value }, { type: 'redis', options: { url: 'REDIS_URL' }, { type: 's3', options: { access_key_id: 'ACCESS_KEY_ID', secret_access_key: 'SECRET_ACCESS_KEY' }, { type: 'nats', options: { url: 'NATS_URL' } ] } })

Other options are the following :

  • custom_health_checks : an array of functions doing custom health checks.
  • feature_health_checks : same type of array as health_checks but if one of theses checks fail, the plugin will not return a failure but a warning.
  • custom_feature_health_checks : an array of functions doing custom health checks. If one of theses health checks fails, the plugin will not return a failure but a warning.

For others use cases, you can look at the tests in the test directory.

== Run tests

To run the tests, you must define some environment variables to execute the tests (or put them in a .env file at the root of this project):

  • DATABASE_URL : url the Postgres database
  • REDIS_URL : url of Redis
  • NATS_URL : url of nats
  • ACCESS_KEY_ID : access key to Amazon S3
  • SECRET_ACCESS_KEY : secret access key to amazon S3

[source,shell] .Execute the tests

npm test

== Licence

link:LICENCE[MIT]