Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sandwichfarm/nostr-watch/llms.txt
Use this file to discover all available pages before exploring further.
@nostrwatch/route66 sits between raw relay checks (performed by @nostrwatch/nocap) and the application layer — GUIs and REST APIs consume route66, not raw check events. It aggregates relay status data from NIP-66 monitors and exposes it through a consistent querying API. Both the cache layer and WebSocket connection layer are independently swappable, allowing route66 to work in browser, Node.js, and worker thread environments.
Installation
Quick start
Route66 class
The main entry point. Wraps the cache and WebSocket adapters and exposes RelayService, MonitorService, and StateManager through a unified interface.
Constructor
An object containing both adapter instances.
Methods
boot()
Initializes workers, services, and waits for adapters to signal readiness. Call once after construction.
ready()
Resolves when initialization is complete. Safe to call multiple times; resolves immediately if already initialized.
shutdown()
Gracefully shuts down all adapters and workers.
restart()
Equivalent to calling shutdown() followed by boot().
Getters
relays — Returns the RelayService instance for relay state queries. Available after boot().
monitors — Returns the MonitorService instance for managing active monitor subscriptions. Available after boot().
state — Returns a reference to the StateManager singleton.
initialized — true once boot() has completed successfully.
StateManager
A static singleton that provides shared state, event emission, and local storage access across all route66 services.
abort() — Cancels all in-flight async operations that respect StateManager.abortSignal. Emits an 'abort' event.
resetAbort() — Creates a new AbortController, re-enabling operations after a previous abort() call.
emit(event, ...args) — Emits a named event to all registered listeners.
set(key, value) / get(key) / remove(key) / clear() — Local storage operations namespaced to the 'state' prefix. Used internally by services to persist lightweight state across page reloads.
ChronicleService
Provides relay history and time series data from Kind 1066 delta events (NIP-66 append-only history log).
ChronicleServiceOptions
Automatically subscribe to Kind 1066 events for queried relays.
Relay URLs to fetch Kind 1066 events from.
TimeSeriesOptions
The relay URL to query.
Start of time range as a Unix timestamp in seconds.
End of time range as a Unix timestamp in seconds.
Type of time series data:
'rtt', 'uptime', or 'changes'.Bucket size in seconds for time-series aggregation.
Aggregation function:
'avg', 'min', 'max', or 'sum'.UptimePeriod fields
Period start timestamp (Unix seconds).
Period end timestamp.
null if the period is still ongoing.Whether the relay was online during this period.
Round-trip time in milliseconds (optional; may be absent — see known limitations).
Example
MonitorService
Manages subscriptions to NIP-66 monitors (Kind 10166 announcements) and tracks which monitors are currently active. Created automatically when Route66 is initialized. Access it via r66.monitors.
array — All known monitors as an array.
map — All known monitors as a Map keyed by monitor pubkey.
enabledMonitors — Monitors that are enabled in the local configuration.
activeEnabledMonitors — Enabled monitors that are currently publishing NIP-66 events.
disabledMonitors — Monitors that have been disabled.
ready() — Resolves when the initial monitor list has been loaded.
Adapter pattern
route66 has two independent adapter dimensions: cache adapters store and query relay state data, and WebSocket adapters connect to monitoring relays over Nostr. Both are provided at construction time.Cache adapter interface
Cache adapters extendCacheAdapter and implement ICacheAdapter:
Existing adapters
NostrSqliteAdapter
SQLite-backed cache storage using
@nostrwatch/worker-relay in a web worker. Works in both browser and Node.js environments.Package: @nostrwatch/route66-cacheadapter-nostrsqliteNostrToolsAdapter
WebSocket implementation using
nostr-tools and nostr-fetch. Used for connecting to NIP-66 monitoring relays.Package: @nostrwatch/route66-wsadapter-nostrtoolsKnown limitations
Incomplete RTT extraction. RTT values are not extracted from chronicle period metadata in
ChronicleService. Uptime and downtime records may be missing RTT data. No workaround is available at this time.Related packages
@nostrwatch/nocap
Performs the raw relay capability checks that produce the NIP-66 events route66 aggregates.
@nostrwatch/auditor
NIP conformance testing; audit results can be published as NIP-66 events.
@nostrwatch/nostrings
Relay URL sanitization; route66 passes relay URLs through nostrings before storage.