ape-status

A simple monitoring helper

Usage no npm install needed!

<script type="module">
  import apeStatus from 'https://cdn.skypack.dev/ape-status';
</script>

README

ape-status

Installation

    npm install ape-status --save

Usage

Initialization

var apeStatus = require("ape-status");

apeStatus.configure({
    root: __dirname                             // required! should be the root path of your application OR the path on the local maschine where you want the APPINFO.json to be.
    
    info: {...}                                 // everything you want to end up in the APPINFO.json (can be also added during startup)
    infoName: "NAME_OF_INFO.json"               // default APPINFO.json 
    path: "/path/for/simple/health/check",      // default /ape/status
    pathBackends: "/path/for/backend/checks"    // default /ape/status/backends,
});

Bind to express instance

var expressApp = require("express")();

expressApp.use(apeStatus.express);

Info File

Add Info

apeStatus.info("port", 1337);

Save To File

apeStatus.saveJSONInfo();

Add Backends

MYSQL Pool

var pool = mysql.createPool({...});

apeStatus.mysql("NAME YOUR CONNECTION", pool, "QUERY TO EXECUTE");  // query parameter is optional

Mongoose connection

mongoose.connect(...);

apeStatus.mongoose(mongoose.connection, "NAME OF A COLLECTION TO CHECK"); // The db name will be used as the name for the status page, the colelction name is optional

Redis connection

apeStatus.redis(redis.client, "Name for this redis");

Webservice

apeStatus.webservice("NAME YOUR WEBSERVICE", "URL TO CHECK");

Response example

/ape/status => 200 OK (no body)

/ape/status/backends

{
    MYSQL-main: {
        connected: true
    },
    WEBSERVICE-googlemaps: {
        available: true,
        response_time: 57   // MS
    },
    MONGOOSE-main: {
        connected: true
    }
}