New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@openreply/emw-health-check

Package Overview
Dependencies
Maintainers
59
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@openreply/emw-health-check

express middleware enables health checks for your service

2.0.3
latest
Source
npm
Version published
Weekly downloads
78
14.71%
Maintainers
59
Weekly downloads
 
Created
Source

Health Check Express Middleware

Health checks are one of the most essential features when it comes to distributed systems. This package provides an express middleware that enables an health checker (e.g. load balancer) to sequentially monitor the health of your service via REST API. Therefor this middleware enables an API endpoint to provide steady information about the health of your service. By default the health endpoint will be provided under GET /health.

If the express server is running and reachable the middleware will provide and success answer (HTTP Status: 200) with information regarding the service (e.g. service name, environment variables, ...). This middleware also listens on all outgoing responses and provides works as a circuit breaker for the service if any endpoint is steadily responding with HTTP Status 500.

By default the healthCheck middleware will listen on every HTTP endpoint registred to the express app.

Getting Started

Installing

you can install this package via npm

npm i @openreply/emw-health-check

Usage

Simply add this module to your middleware chain

app.use(healthCheck({ serviceName: 'testService' }));

See the following usage example

/* eslint-disable import/no-extraneous-dependencies */
const request = require('request');
const express = require('express');
/* eslint-enable import/no-extraneous-dependencies */
const healthCheck = require('@openreply/emw-health-check');

const app = express();

// initializes our healthCheck middleware. will also set the trace header on
// the response object by default
app.use(healthCheck({ serviceName: 'testService' }));

app.listen(3000, () => {
  // eslint-disable-next-line no-console
  console.log('Example app listening on port 3000!');
});

Running the tests

You can run the test suite via

npm test

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Dominik Riedel - Initial work - openreply-de

See also the list of authors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

References

Keywords

healthcheck

FAQs

Package last updated on 12 Jun 2023

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