npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@utilitywarehouse/uw-lib-operational.js

v1.0.3

Published

node.js implementation of UW operational endpoints spec

Downloads

51

Readme

Operational Endpoints for node.js

Ready

  • Ready.constructor - check constructor
  • Ready.handler - is the standard middleware handler for your http server, it returns responses as per UW operational endpoints spec - https://github.com/utilitywarehouse/operational-endpoints-spec/blob/master/READY.md
  • Ready.onCall(func callback) - registers a callback to be fired on each invocation of the handler. The callback gets an instance of the reporter as argument,You are required to call one of the reprter methods otherwise the middleware won't progress.
  • Reporter.ready - indicates the service is ready
  • Reporter.waiting - indicated the service is not ready yet

Health

  • Health.constructor(string name, string description) - check constructor
  • Health.handler - is the standard middleware handler for your http server, it returns responses as per UW operational endpoints spec - https://github.com/utilitywarehouse/operational-endpoints-spec/blob/master/HEALTH.md
  • Ready.addCheck(string name, func callback) - registers a callback under given name to be executed on each invocation of the handler. The callback gets an instance of the reporter as argument,You are required to call one of the reporter methods otherwise the middleware won't progress.
  • Reporter.healthy(string output) - indicates the check is healthy with given output
  • Reporter.degraded(string output, string action) - indicates the check is in degraded state with given output and action to be taken to fix the issue
  • Reporter.unhealthy(string output, string action, string impact) - indicates the check is in unhealthy state with given output, action to be taken to fix the issue as well as the impact the issue has on the service

About

  • About.constructor - constructor
  • About.handler - is the standard middleware handler for your http server, it returns responses as per UW operational endpoints spec - https://github.com/utilitywarehouse/operational-endpoints-spec/blob/master/ABOUT.md
  • About.fromFile(string filePath) - will synchronously load properties from a JSON file
  • About.setMeta(string name, string description) - sets meta name information
  • About.addOwner({string name, string slack, string email}) - adds ownership information (can add multiple owners by calling this method multiple times)
  • About.addLink(string description, string link) - adds link information (can add multiple links by calling this method multiple times)
  • About.setBuildInfo({string revision, ...info}) - adds build information
  • About.addOther(key, value) - adds arbitrary value, key will be automatically prefixed with _

Build info

For CI there's an extra command line tool provided called build-info:

  Usage: build-info [options]

  Options:

    -h, --help              output usage information
    -V, --version           output the version number
    -l --link <string>      link to build
    -n --number <string>    build number
    -r --revision <string>  code revision
    -o --output [string]    output file

Circle info

For convinience, above command has been preconfigured to read from CircleCI environment, available as circle-info.

Example

const express = require('express');
const operational = require('../index');
const path = require('path');

const app = express();

const ready = new operational.Ready();
const health = new operational.Health();
const about = new operational.About();

ready.onCall(r => {
	r.ready();
});

health.addCheck('api', r => {
	r.healthy('api is available');
});

health.addCheck('cache', r => {
	r.degraded('redis went away', 'check pods');
});

health.addCheck('db', r => {
	r.unhealthy('db not configured', 'configure db', 'app unusable');
});

about.setMeta('name', 'description');
about.addOwner({name: 'Web Systems Team', slack: '#web-systems', email: '[email protected]'});
about.addLink('README', 'https://github.com/utilitywarehouse/uw-lib-operational.js/README.md');
about.fromFile(path(__dirname, 'build.json'));

app.use('/__/about', about.handler);
app.use('/__/ready', ready.handler);
app.use('/__/health', health.handler);

app.listen(3000, () => {
	console.log('Example ready on http://0.0.0.0:3000');
});