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

@healthzkit/mysql

v0.0.6

Published

MySQL health-check adapters for healthzkit (mysql and mysql2).

Readme

@healthzkit/mysql

MySQL healthzkit HealthAdapter helpers for mysql (legacy callback driver) and mysql2 (promise API). Successful checks run a lightweight SQL probe (default SELECT 1) and return ok with metadata.latencyMs plus any fields from an optional metadata hook; failures return fail with the caught error.

Install

npm install @healthzkit/mysql healthzkit
# plus one of:
npm install mysql
npm install mysql2

mysql and mysql2 are optional peers—install the driver you use.

Package entrypoints

| Import | Exports | | -------------------------- | ------------------------------------------ | | @healthzkit/mysql | mysqlAdapter, mysql2Adapter, and types | | @healthzkit/mysql/mysql | mysqlAdapter only | | @healthzkit/mysql/mysql2 | mysql2Adapter only |

Use subpath imports when you want to avoid pulling both drivers into your bundle analysis path.

Shared options

Both factories accept BaseMysqlOptions:

| Option | Description | | ---------- | ------------------------------------------------------------------------------------------------- | | query | SQL executed for the probe. Default SELECT 1. | | metadata | Optional async (client) => Record<string, unknown> merged into check metadata with latencyMs. |

Pass either connectionString or client (not both).

mysqlAdapter (mysql)

Peer: mysql ≥ 2.18.

Each check acquires a connection, runs connection.query(query), records round-trip latency, and **release()**s pooled connections in a finally block.

Connection string

The adapter lazily imports mysql, parses a mysql:// or mysql2:// URL, and creates a shared internal Pool. Concurrent checks reuse that pool.

import { createHealthKit } from "healthzkit";
import { mysqlAdapter } from "@healthzkit/mysql";

const kit = createHealthKit({
  checks: [
    {
      name: "mysql",
      type: ["readiness"],
      adapter: mysqlAdapter({
        connectionString: process.env.DATABASE_URL!,
        connectionOptions: { connectTimeout: 2000 },
      }),
    },
  ],
});

Existing client or pool

Pass client as:

  • A Pool: each check calls pool.getConnection(), runs the query, then releases the connection.
  • A Connection: the query runs on that instance; release is a no-op when the connection has no release method.
import mysql from "mysql";
import { mysqlAdapter } from "@healthzkit/mysql/mysql";

const pool = mysql.createPool({ host: "localhost", user: "app", database: "app" });

const adapter = mysqlAdapter({
  client: pool,
  query: "SELECT VERSION()",
  metadata: async (conn) => {
    return { threadId: conn.threadId };
  },
});

mysql2Adapter (mysql2)

Peer: mysql2 ≥ 3.

Uses the promise API from mysql2/promise. Each check acquires a connection, awaits connection.query(query), records latency, and releases pooled connections when applicable.

Connection string

Pass connectionString and connectionOptions (PoolOptions merged into the internal pool). The adapter lazily imports mysql2/promise, parses mysql:// or mysql2:// URLs, and reuses one internal pool across checks.

import { mysql2Adapter } from "@healthzkit/mysql/mysql2";

const adapter = mysql2Adapter({
  connectionString: process.env.DATABASE_URL!,
  connectionOptions: { connectionLimit: 2 },
});

Existing client or pool

Pass client as a Pool or Connection from your app—the same acquire → query → release behavior applies.

import mysql from "mysql2/promise";
import { mysql2Adapter } from "@healthzkit/mysql";

const pool = mysql.createPool(process.env.DATABASE_URL!);

const adapter = mysql2Adapter({
  client: pool,
  metadata: async () => ({ driver: "mysql2" }),
});

Connection strings

Both adapters accept URLs with the mysql:// or mysql2:// scheme (default port 3306). Userinfo and database name are taken from the URL; additional pool settings go in connectionOptions.

mysql://user:[email protected]:3306/myapp
mysql2://localhost:3307/myapp

Check result

On success:

{
  "status": "ok",
  "metadata": { "latencyMs": 4 }
}

On failure, status is "fail" and error is set (see healthzkit for how that rolls up into probe responses).

Scheduling

For busy databases, pair these adapters with a schedule on the check so readiness reads cached results instead of running SQL on every probe. See the Scheduling section in the healthzkit README.

Development

From the monorepo root:

vp install
vp test --filter @healthzkit/mysql
vp pack --filter @healthzkit/mysql