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 🙏

© 2026 – Pkg Stats / Ryan Hefner

status-sdk

v1.0.9

Published

Status SDK

Readme

Status SDK

SDK for status check & reporting

How to use


ESM:

import { status } from 'status-sdk';

CJS:

const { status } = require('status-sdk');

Upon calling the enable function, the Status SDK will initiate the process monitor and automatically transmit crash/unhandled events to your Status API, as specified in the function parameters.

Setup for automatic unhandled promise/exception report

status.enable({
  // Site ID to be reported
  siteId: '<your_site_id>',
  // API key of the Status API
  apiKey: '<your_api_key>',
  // API URL for serving the status report
  apiUrl: 'https://your_domain/your/api/context/path'
});

The Status SDK does not assist in managing uncaught exceptions; when they occur, the application will shut down. If any unhandled promises are present, a warning will be generated, such as PromiseRejectionHandledWarning: Promise rejection was handled asynchronously, since the unhandled promises are intercepted by the Status SDK.

Codes to indicate the status being reported

| Group | Status flag | | ----------- | ----------------------------------- | | Good | UP | | Information | INFO, DEBUG | | Unknown | UNKNOWN | | Warning | TIMEOUT, WARNING, MAINTENANCE | | Danger | OUTAGE, CRASH, ERROR |

Active report

The active report function executes an HTTP request to your Status API and returns an HTTP code. In its implementation, there is no promise rejection, making the try ... catch block unnecessary. This is done to prevent the generation of infinite calls when the app fails due to unhandled promises.

import { status, FLAGS } from 'status-sdk';
const { code, data } = await status.report(FLAGS.ERROR, 'This is an error.');

console.log(code, data);

Events

Status SDK inherits EventEmitter class in order to emit or listen on the events defined blow:

| Description | Status code | | --------------------------------------- | ----------- | | Automatic report enabled | ENABLED | | Automatic report disabled | DISABLED | | Fires when it is sending warning report | WARNING | | Fires when the report is sent | REPORTED | | The final signal when the app crashes | EXIT |

And this is how it can be used:

import { status, EVENTS } from 'status-sdk';

status.on(ENABLED, () => {
  // The status SDK is enabled for collecting data for report
});
status.on(DISABLED, () => {
  // The status SDK is disabled
});

// status.enable({ ... });

Status API standard


The Status API serves the purpose of collecting status data, processing it, and generating reports. It must be compatible with the data sent by the Status SDK.

  1. POST method is required with apikey header to verify the identity of the HTTP request
  2. id as the path parameter to determine an environment/application
  3. body data payload format
{
  "status": "enum", // See the note blow
  "logs": "string",
  "cpu": {
    "user": "number",
    "system": "number"
  },
  "memory": {
    "rss": "number",
    "heapTotal": "number",
    "heapUsed": "number",
    "external": "number",
    "arrayBuffers": "number"
  },
}

Full example of setup


import { status } from 'status-sdk';

status.enable({
  // Site ID to be reported
  siteId: '000001',
  // API key of the Status API
  apiKey: 'apikey',
  // API URL for serving the status report
  apiUrl: 'https://mihui.net/api/status/report',
  // Set to true to disable the automatic error/crash report, by default it is set to false
  manualOnly: false,
  // Custom headers to the Status API, `apikey` is preserved above
  headers: { key: 'value' }
});

Other useful methods


// Disable Status SDK
disable(userProcess: NodeJS.Process|undefined): StatusInterface;

// Get request URL
getRequestUrl() : string;

// Get API URL
getApiUrl(): string;

// Set API URL
setApiUrl(apiUrl: string): void;

// Add HTTP header
addHeader(key: string, value: string): void;

// Get HTTP headers
getHeaders(): http.OutgoingHttpHeaders;