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

@mokei/app-node

v0.15.0

Published

Mokei Node app foundation: configuration, database and telemetry

Readme

@mokei/app-node

Node app foundation for Mokei configuration, the shared hozon database and process telemetry.

Public API

| Export | Behaviour | |---|---| | getMokeiConfigPath() | Returns MOKEI_CONFIG_PATH or <mokei data dir>/mokei.json. | | loadMokeiConfig(path?) | Loads and validates configuration; missing files use defaults. | | MokeiConfig, MokeiConfigError | Configuration type and validation error (with path and issues). | | mokeiStoreDefinitions | Built-in hozon log, telemetry and trace index store definitions. | | openMokeiDatabase({ path?, stores? }?) | Opens and migrates the app database, registering built-in stores and any supplied definitions. | | setupMokeiTelemetry({ provider, onEvent?, hasListeners?, flushIntervalMs?, otlp?, service?, logs?, reportCategories? }) | Installs process tracing and logging; returns the recorder and asynchronous dispose(). | | LocalTraceRecorder | Records spans, correlated logs and trace summaries with bounded queues and live delivery. | | createTraceReader({ provider, recorder }) | Queries persisted traces merged with the recorder's live snapshot. | | traceIndexStoreDefinition, getTraceIndexStore(provider) | Registers and accesses the trace summary index. | | toOpenSpan(span), toStoredSpan(span) | Converts OpenTelemetry spans into live and persisted representations. |

mokei.json

The default path is <mokei data dir>/mokei.json; MOKEI_CONFIG_PATH overrides it and an explicit loadMokeiConfig(path) wins. The schema rejects unknown keys at every level. Missing file defaults are { "logs": { "level": "info", "file": true }, "tracing": { "payloads": "on" } }.

{
  "logs": { "level": "info", "file": true },
  "tracing": {
    "payloads": "on",
    "parentFrom": "context",
    "otlp": {
      "endpoint": "http://localhost:4318/v1/traces",
      "metricsEndpoint": "http://localhost:4318/v1/metrics",
      "headers": { "authorization": "Bearer token" }
    }
  }
}

logs.level accepts trace, debug, info, warning, error or fatal; logs.file controls daily rotating file output. tracing.payloads accepts on, off or a positive integer byte cap, and defaults to on. tracing.parentFrom accepts context (default; incoming MCP spans parent on the context span) or meta (parent on the _meta trace context, context span linked). tracing.otlp.endpoint is required when otlp is present; metricsEndpoint is optional and defaults to the endpoint with a trailing /v1/traces replaced by /v1/metrics (metrics export is off when neither applies); headers is an optional string map. Invalid JSON and schema values throw MokeiConfigError, naming the path and validation issues.

Database and telemetry

openMokeiDatabase() uses <mokei data dir>/mokei.db. MOKEI_DATABASE_PATH overrides the default; an explicit path takes precedence over the environment variable. :memory: selects in-memory storage. The database registers mokeiStoreDefinitions (the hozon log, telemetry and trace index stores) plus optional caller-provided stores.

Telemetry stores spans and correlated logs locally, and can export spans and metrics to OTLP. service: { name?, version? } sets the Resource service.name (default mokei) and service.version. Content attributes follow tracing.payloads or OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true. File logging is enabled by default. MCP notification logs reach the recorder at debug level without reaching other sinks.

hasListeners(type) skips live event cloning and dispatch when no listener exists. flushIntervalMs overrides the recorder's flush interval. reportCategories is an array of logger category paths; each is routed at error level to the console error sink and excluded from log capture. The hozon category is routed there automatically. Hozon storage failures also reach the console error sink without being captured.

Dispose application work first, then telemetry, then close the database. Telemetry is process-wide and can only be installed once.