@sparkit-gmbh/express-health-check
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

express-health-check

A simple middleware that returns the availability of the API and related services.

Getting started

Install with:

npm install --save @sparkit-gmbh/express-health-check

Use it in your express app:

const app = require('express')();
const statusMonitor = require('@sparkit-gmbh/express-health-check');

// Default
app.use(statusMonitor());

// With DB Monitor (Mongoose / Sequelize / IORedis)

// With Custom URL Path
app.use(status({ path: '/api/status', db: true }));

// respond with "hello world" when a GET request is made to the homepage
app.get('/', function(req, res) {
    res.send('hello world');
});

app.listen(3000, function () {
    console.log('Example app listening on port 3000!')
});

Options

Custom URL Path

{ path: '/status'}

API Monitoring: Enable/Disable

{ api: true }

System Monitoring: Enable/Disable

{ system: true }

DB Monitoring: Enable/Disable

{ db: true }

If DB is set to true, a DB instance should be provided

  • Mongoose { mongoose: mongoose }
  • Sequelize { sequelize: sequelize }
  • IORedis { ioredis: ioredisInstance }

DB Monitoring support

  • [x] Mongoose ORM (MongoDB)
  • [x] Sequelize ORM (MySQL, PostgreSQL, SQlite, ...)
  • [x] IORedis (Redis)
  • [ ] MongoDB (coming soon)

Extras

You can return any JSON data with the extras property

{
    extras: {
        infoA: 1234
        infoB: 1234
        infoC: 'somethin'
    }
}

Feedback

Suggestions or improvements are most welcomed ! Open an issue if you want to help.

Author

Piraveen Kamalathas https://github.com/piraveen

Package Sidebar

Install

npm i @sparkit-gmbh/express-health-check

Weekly Downloads

26

Version

1.0.3

License

MIT

Unpacked Size

10.3 kB

Total Files

8

Last publish

Collaborators

  • piraveen