1.0.2 • Published 5 years ago

server-status-utils v1.0.2

Weekly downloads
46
License
MIT
Repository
github
Last release
5 years ago

Server status utilities

This module provides an internal status page for Express based servers. The status page is aimed for developers and shows useful info for diagnostics or troubleshooting, for example the application version and recent requests.

See an example of the status page.

Usage

To use, first require the module and create a ServerStatus object:

const serverStatus = require("server-status-utils")
const ss = new serverStatus.ServerStatus()

Connect the collectRequestStats handler to track all requests (before all other handlers that may respond to a request). It is safest to put this as the first handler:

app.use("/", ss.collectRequestStats.bind(ss))

Connect the statusPage handler to a specific GET path of your choice. This can be done at any point in your express handlers:

app.get("/status", ss.statusPage.bind(ss))

A usage example is included. To run the example use npm:

npm install
npm run example

Tests

To run the test suite use npm:

npm install
npm test

A coverage report will be produced in the coverage directory.