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

mbkhealth

v1.0.1

Published

Comprehensive application health testing, route discovery, asset validation, and console error detection for MBKTech Node.js/Express applications

Readme

mbkhealth

Comprehensive application health testing, route discovery, asset validation, and console error detection for MBKTech Node.js/Express applications.

License: MIT

Features

  • 🔒 Protected Health Testing: Trigger comprehensive test runs through a protected POST /api/health/test endpoint secured by an API key or shared secret.
  • Standard Liveness Endpoint: Instant GET /api/health and GET /health responding with standardized JSON status and uptime.
  • 🗺️ Automatic Route Discovery: Recursively introspects Express router stacks, sub-routers, dynamic routes, and sitemaps (/sitemap.xml) to discover all public pages.
  • 🧪 Deep Functional Verification (Not just HTTP 200!):
    • Content Checks: Verifies presence of <title>, <body>, non-empty DOM, and custom expected content strings.
    • Backend Error Detection: Identifies 5xx errors, unhandled exceptions, leaked stack traces, and database connection failures.
    • Frontend Console Errors: Leverages JSDOM virtual console to catch client-side console.error, unhandled exceptions, and script syntax errors.
    • CSS Validation: Verifies that stylesheets return HTTP 200 with text/css and that CSS selectors match elements on the page.
    • Asset Verification: Checks that images (<img>), icons (<link rel="icon">), and media load successfully with zero 404s.
  • 📊 Structured JSON Reports: Detailed overall health status (healthy, degraded, unhealthy), summary metrics, system diagnostics (memory, uptime), and granular per-route results.
  • 🧩 Zero-Overhead Integration: Drop into any Express app with just 2 lines of code.

Installation

npm install mbkhealth

Quick Start (Express Integration)

In your application's src/app.js:

import express from "express";
import { createHealthRouter } from "mbkhealth";

const app = express();

// ... other middleware and routes ...

// Mount health testing endpoints under /api/health
app.use("/api/health", createHealthRouter({
  appName: "my-mbktech-app",
  secretKey: process.env.HEALTH_TEST_KEY || "your-secret-key",
}));

// Also alias /health if desired
app.get("/health", (req, res) => res.redirect("/api/health"));

Endpoints

1. GET /api/health (Public Liveness Ping)

Fast, lightweight check for monitoring agents and load balancers.

Response (200 OK):

{
  "success": true,
  "status": "healthy",
  "app": "my-mbktech-app",
  "uptime": 450.2,
  "timestamp": "2026-09-11T18:30:00.000Z",
  "version": "1.0.0"
}

2. POST /api/health/test (Protected Health Testing Suite)

Runs deep health testing across all discovered application pages.

Authentication: Provide the secret key using any of the following headers:

  • x-health-key: your-secret-key
  • Authorization: Bearer your-secret-key
  • x-api-key: your-secret-key

Example cURL Request:

curl -X POST http://localhost:4133/api/health/test \
  -H "x-health-key: your-secret-key" \
  -H "Content-Type: application/json" \
  -d '{ "checkAssets": true, "checkCss": true }'

Response (200 OK or 503 Service Unavailable if unhealthy):

{
  "success": true,
  "health": "healthy",
  "appName": "mbktech.org",
  "timestamp": "2026-09-11T18:35:10.123Z",
  "durationMs": 420.5,
  "summary": {
    "totalRoutesChecked": 14,
    "passed": 14,
    "failed": 0,
    "warnings": 1,
    "totalAssetsChecked": 32,
    "assetsFailed": 0,
    "totalConsoleErrors": 0
  },
  "system": {
    "uptime": 1250.4,
    "memoryUsage": {
      "heapUsedMb": 42.15,
      "heapTotalMb": 85.2,
      "rssMb": 110.8
    },
    "nodeVersion": "v25.2.1",
    "environment": "production",
    "platform": "win32 (x64)"
  },
  "routes": [
    {
      "path": "/",
      "method": "GET",
      "status": 200,
      "durationMs": 35.1,
      "health": "healthy",
      "contentType": "text/html; charset=utf-8",
      "contentChecks": {
        "hasTitle": true,
        "title": "MBK Tech",
        "hasBody": true,
        "backendErrorDetected": false
      },
      "consoleErrors": [],
      "cssChecks": {
        "stylesheetsFound": 2,
        "stylesheetsLoaded": 2,
        "stylesApplied": true,
        "matchingRulesCount": 18,
        "errors": []
      },
      "assetChecks": {
        "totalAssets": 5,
        "assetsTested": 5,
        "loadedAssets": 5,
        "failedAssets": []
      },
      "errors": [],
      "warnings": [],
      "logs": [
        "Testing /...",
        "Received HTTP 200 in 35.1ms",
        "CSS: 2/2 loaded, applied=true",
        "Assets: 5/5 loaded, failed=0"
      ]
    }
  ]
}

Standalone / Programmatic Usage

You can also run health checks programmatically (for example, in CI/CD pipelines or Vitest/Jest suites):

import { runHealthCheck } from "mbkhealth";
import app from "./src/app.js";

const report = await runHealthCheck(app, {
  appName: "my-app",
  includeRoutes: ["/", "/about", "/contact"],
  checkAssets: true,
  checkCss: true,
  checkConsole: true,
});

console.log("Overall Health:", report.health);
console.log("Passed:", report.summary.passed, "Failed:", report.summary.failed);

Configuration Options

| Option | Type | Default | Description | | :--- | :--- | :--- | :--- | | appName | string | process.env.APP_NAME or "mbktech-app" | Application identifier in reports | | secretKey | string | process.env.HEALTH_TEST_KEY | Secret key for protecting POST /test | | includeRoutes | string[] | [] | Additional routes to test | | excludeRoutes | string[] | ["/favicon.ico", "/api/health*"] | Routes to skip | | routeParams | object | { ":id": "1", ":slug": "test" } | Replacement values for parameterized routes | | checkAssets | boolean | true | Verify image, icon, and media URLs (HTTP 200) | | checkCss | boolean | true | Verify stylesheet HTTP 200 and DOM matching | | checkConsole | boolean | true | Verify zero frontend JS and console errors | | checkSitemap | boolean | true | Discover routes from /sitemap.xml | | timeoutMs | number | 15000 | Per-route request timeout | | maxAssetsPerPage | number | 20 | Maximum assets to check per page | | expectedContent | object | {} | Map of route path to array of required strings |


License

MIT © Muhammad Bin Khalid & MBKTech.org