Skip to content

Dashboard

The dashboard package provides a browser-based UI for monitoring your cache, dedup, and rate limit stores in real time. It supports multiple named clients, works with all store backends (Memory, SQLite, DynamoDB), and auto-detects capabilities.

Dashboard overview showing cache, dedup, and rate limit store summaries for the user-api client
Terminal window
npm install @http-client-toolkit/dashboard

Mount the dashboard inside an existing HTTP server using createDashboard(). Pass in one or more HttpClient instances — the dashboard reads their stores automatically:

import http from 'http';
import { HttpClient } from '@http-client-toolkit/core';
import { createDashboard } from '@http-client-toolkit/dashboard';
import {
InMemoryCacheStore,
InMemoryDedupeStore,
InMemoryRateLimitStore,
} from '@http-client-toolkit/store-memory';
const userApiClient = new HttpClient({
name: 'user-api',
cache: { store: new InMemoryCacheStore() },
dedupe: new InMemoryDedupeStore(),
rateLimit: { store: new InMemoryRateLimitStore() },
});
const productApiClient = new HttpClient({
name: 'product-api',
cache: { store: new InMemoryCacheStore() },
rateLimit: { store: new InMemoryRateLimitStore() },
});
const dashboard = createDashboard({
clients: [
{ client: userApiClient },
{ client: productApiClient },
],
});
const server = http.createServer(dashboard);
server.listen(4000, () => {
console.log('Dashboard at http://localhost:4000');
});

The middleware signature is (req, res, next?) => void, so it works with plain http.createServer, Express, Connect, and similar frameworks.

Use createDashboardHandler() for frameworks and runtimes that use the Web Standards Request/Response API — such as Hono, Bun, and Deno:

import { HttpClient } from '@http-client-toolkit/core';
import { createDashboardHandler } from '@http-client-toolkit/dashboard';
import { InMemoryCacheStore, InMemoryDedupeStore, InMemoryRateLimitStore } from '@http-client-toolkit/store-memory';
const userApiClient = new HttpClient({
name: 'user-api',
cache: { store: new InMemoryCacheStore() },
dedupe: new InMemoryDedupeStore(),
rateLimit: { store: new InMemoryRateLimitStore() },
});
const handler = createDashboardHandler({
clients: [{ client: userApiClient }],
});

The handler signature is (request: Request) => Promise<Response>, so it plugs directly into any Web Standards-compatible server:

import { Hono } from 'hono';
const app = new Hono();
app.all('/dashboard/*', (c) => handler(c.req.raw));

For convenience, startDashboard() spins up its own HTTP server:

import { HttpClient } from '@http-client-toolkit/core';
import { startDashboard } from '@http-client-toolkit/dashboard';
import { InMemoryCacheStore, InMemoryDedupeStore, InMemoryRateLimitStore } from '@http-client-toolkit/store-memory';
const userApiClient = new HttpClient({
name: 'user-api',
cache: { store: new InMemoryCacheStore() },
dedupe: new InMemoryDedupeStore(),
rateLimit: { store: new InMemoryRateLimitStore() },
});
const { server, close } = await startDashboard({
clients: [{ client: userApiClient }],
port: 4000,
host: 'localhost',
});
// Later...
close();

When multiple clients are configured, the sidebar displays a client selector. Each client has its own independent stores, and the navigation adapts to show only the views available for the selected client.

Dashboard showing product-api client with only Cache and Rate Limit views available

Client names must be URL-safe (letters, numbers, hyphens, underscores) and unique within a dashboard instance.

View cached responses with stats for total items, memory usage, and expired entries. Supports paginated entry listing, individual deletion, and bulk clearing.

Cache view showing stats cards and entry listing with pagination

Monitor request throttling with per-resource utilization, request counts, and window durations. Reset individual resource counters when supported by the backend.

Rate limit view showing resource table with utilization badges and reset buttons

Track active deduplication jobs and total processed count. View individual job details when using a backend that supports listing.

Each client in the clients array accepts:

OptionTypeRequiredDescription
clientHttpClientYesAn HttpClient instance with at least one store configured
namestringNoOverride the client’s name for the dashboard (defaults to client.name)

The dashboard reads stores directly from the HttpClient instance via its stores property. At least one store (cache, dedupe, or rateLimit) must be configured on the client.

OptionTypeDefaultDescription
clientsClientConfig[]One or more named clients (required)
basePathstring'/'URL prefix for the dashboard
pollIntervalMsnumber5000How often the UI polls for updates (ms)

Extends DashboardOptions with:

OptionTypeDefaultDescription
portnumber4000Port number for the standalone server
hoststring'localhost'Host to bind to

The dashboard uses runtime detection to identify which store implementation you’ve passed in and wraps it with a backend-specific adapter. No changes to your store code are required.

BackendCacheDedupRate Limit
MemoryStats, list entries, view/delete/clearStats, list jobs, view jobStats, list resources, view/reset/configure
SQLiteStats, list entries, view/delete/clearStats, list jobs, view jobStats, list resources, view/reset/configure
DynamoDBStats onlyStats onlyStats only
UnknownStats onlyStats onlyStats only

The dashboard exposes a REST API that the React SPA consumes. All store endpoints are scoped per client under /api/clients/:name/.

MethodEndpointDescription
GET/api/healthAggregate health with all clients and capabilities
GET/api/clientsList all clients and their store types
GET/api/clients/:name/cache/statsCache statistics
GET/api/clients/:name/cache/entries?page=0&limit=50List cache entries
GET/api/clients/:name/cache/entries/:hashGet a single cache entry
DELETE/api/clients/:name/cache/entries/:hashDelete a cache entry
DELETE/api/clients/:name/cache/entriesClear all cache entries
GET/api/clients/:name/dedup/statsDedup statistics
GET/api/clients/:name/dedup/jobs?page=0&limit=50List dedup jobs
GET/api/clients/:name/dedup/jobs/:hashGet a single dedup job
GET/api/clients/:name/rate-limit/statsRate limit statistics
GET/api/clients/:name/rate-limit/resourcesList rate-limited resources
GET/api/clients/:name/rate-limit/resources/:nameGet resource status
PUT/api/clients/:name/rate-limit/resources/:name/configUpdate resource config
POST/api/clients/:name/rate-limit/resources/:name/resetReset a resource counter
  • Retry metrics — Show requests that required retries and their success rate. The core HttpClient retry loop currently doesn’t persist metrics, so this would require adding internal retry tracking (total attempts, successes after retry, final failures) and exposing it via a new dashboard adapter.