server-status-utils

1.0.2 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i server-status-utils

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

15.2 kB

Total Files

9

Last publish

Collaborators

  • nava