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

health-checking-service

v1.0.3

Published

health checker for node and can custom

Downloads

17

Readme

health-checking-service

test GitHub Workflow Status (event) Coverage Status License Status Issues Status

This is a Node package that allows you to track the health of your application, providing two ways of checking:

Simple: will respond to a JSON as below and that allows you to check if your application is online and responding without checking any kind of integration.

{
  "status": "pong"
}

Detailed: will respond a JSON as below and that allows you to check if your application is up and running and check if all of your integrations informed in the configuration list is up and running.

{
	"name": "example",
	"version": "v1.0.0",
	"status": false,
	"date": "2022-09-23T07:26:51.369Z",
	"duration": 0.221,
	"integrations": [
		{
			"name": "local-redis",
			"type": "Redis integration",
			"url": "xxxxxxxxxxxx",
			"status": 200,
			"responseTime": 0.006
		},
		{
			"name": "ui api service",
			"type": "Web service integration",
			"url": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
			"status": 403,
			"responseTime": 0.215,
			"error": {
				"action_type": 2,
				"error": 90309999,
				"is_customized": false
			}
		},
		{
			"name": "local-timescale",
			"type": "Database integration",
			"url": "xxxxxxxxxxxx",
			"status": 200,
			"responseTime": 0.044,
			"dialect": "postgres"
		},
		{
			"name": "local-postgres",
			"type": "Database integration",
			"url": "xxxxxxxxxxxx",
			"status": 200,
			"responseTime": 0.162,
			"dialect": "postgres"
		},
		{
			"name": "dev-mariadb",
			"type": "Database integration",
			"url": "xxxxxxxxxxxx",
			"status": 200,
			"responseTime": 0.157,
			"dialect": "mariadb"
		},
		{
			"name": "staging-mysql",
			"type": "Database integration",
			"url": "xxxxxxxxxxxx",
			"status": 200,
			"responseTime": 0.22,
			"dialect": "mysql"
		},
		{
			"name": "local-sqlite",
			"type": "Database integration",
			"status": 200,
			"responseTime": 0.004,
			"dialect": "sqlite"
		},
		{
			"name": "dev-sqlite",
			"type": "Database integration",
			"status": 200,
			"responseTime": 0.004,
			"dialect": "sqlite"
		},
		{
			"name": "minio",
			"type": "Object storage integration",
			"url": "xxxxxxxxxxxxxxxxxxxxxxx",
			"status": 200,
			"responseTime": 0.131,
			"dialect": "minio"
		},
		{
			"name": "s3",
			"type": "Object storage integration",
			"url": "xxxxxxxxxxxxxxxxxxxxxxx",
			"status": 200,
			"responseTime": 0.133,
			"dialect": "aws"
		}
	]
}

How to install

npm i health-checking-service

Available integrations

  • [X] Redis
  • [X] Web service integration
  • [X] Object storage integration (s3, minio)
  • [X] Database integration (postgres, mysql, mariadb, sqlite)
  • [X] Custom integration support

How to use

Example using Nodejs + Express

const express = require('express');
const {
    detailChecking, simpleChecking, healthType, healthDialect,
} = require("health-checking-service");

const app = express();

app.get('/health-check/', (req, res) => {
    res.json({ status: "I'm alive!" });
})
app.get('/health-check/liveness', (req, res) => {
    res.json(simpleChecking())
})
app.get('/health-check/readiness', async (req, res) => {
    const result = await detailChecking({
	name: "example",
	version: "v1.0.0",
	integrations: [
		{
			type: healthType.REDIS,
			name: "local-redis",
			host: "xxxxxxxxxx",
			port: 6379,
		},
		{
			type: healthType.WEB_SERVICE,
			name: "api service",
			host: "https://xxxxxxxxxxx/",
			headers: [
				{ key: "Accept", value: "application/json" },
				{
					key: "Authorization",
					value: "Bearer ey......",
				},
			],
		},
		{
			type: healthType.DATABASE,
			name: "local-postgres",
			host: "xxxxxxxxxx",
			port: 5432,
			dbName: "xxxxxxxxxx",
			user: "xxxxxxxxxx",
			password: "xxxxxxxxxx",
			dialect: healthDialect.DATABASE.postgres,
		},
		{
			type: healthType.DATABASE,
			name: "local-mariadb",
			host: "localhost",
			port: 3306,
			dbName: "xxxxxxxxxx",
			user: "xxxxxxxxxx",
			password: "xxxxxxxxxx",
			dialect: healthDialect.DATABASE.mariadb,
		},
		{
			type: healthType.DATABASE,
			name: "local-mariadb",
			host: "localhost",
			port: 3306,
			dbName: "xxxxxxxxxx",
			user: "xxxxxxxxxx",
			password: "xxxxxxxxxx",
			dialect: healthDialect.DATABASE.mysql,
		},
		{
			type: healthType.DATABASE,
			name: "local-sqlite",
			filename: "path to .sqlite file",
			dialect: healthDialect.DATABASE.sqlite,
		},
		{
			type: healthType.OBJECT_STORAGE,
			name: "minio",
			endPoint: "xxxxxxxxxx",
			accessKey: "xxxxxxxxxx",
			secretKey: "xxxxxxxxxx",
			dialect: healthDialect.OBJECT_STORAGE.minio,
		},
		{
			type: healthType.OBJECT_STORAGE,
			name: "s3",
			endPoint: "xxxxxxxxxx",
			accessKey: "xxxxxxxxxx",
			secretKey: "xxxxxxxxxx",
			region: "xxxxxxxxx",
			dialect: healthDialect.OBJECT_STORAGE.aws,
		},
		{
			type: healthType.CUSTOM,
			name: "custom",
			checking: async () => {
				// do some thing
				return {
					status: 200, // || 500
					responseTime: 0,
					error: "",
				};
			},
		},
	],
});
    res.json(result);
})
app.listen(3000, () => {
    console.log('server started at port 3000')
})