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

@dirwell/server

v0.0.10

Published

Host-neutral directory listing Request/Response handler.

Readme

@dirwell/server

Requires Node.js 22.12 or later. Read the guide.

createExplorerHandler returns an async Request -> Response handler for local filesystem roots. Pass a theme explicitly to enable HTML; no theme or HTTP framework is installed implicitly.

Run a live folder

npm install @dirwell/[email protected] @dirwell/[email protected]

Create files/note.txt, save this as server.mjs, then run node server.mjs:

import { startExplorerServer } from "@dirwell/server/node";
import { createPlainTheme } from "@dirwell/theme-plain";
const server = await startExplorerServer({ root: "./files", theme: createPlainTheme() });
console.log(`${server.url}/browse/`);
process.once("SIGINT", async () => {
  await server.close();
});

Open the printed URL. It reads current files and serves selected bytes on loopback; Ctrl+C closes its connections. The Fetch handler below integrates into a Node application, where the host owns request forwarding and shutdown.

Mount a Fetch handler

import { createExplorerHandler } from "@dirwell/server";
import { createPlainTheme } from "@dirwell/theme-plain";
const handler = await createExplorerHandler({
  root: "./files",
  theme: createPlainTheme(),
  mountPath: "/downloads",
  files: "media",
  live: { intervalMs: 1000, maxClients: 32 },
  headers: () => ({ "Cache-Control": "no-store" }),
});

Routes and publication

/browse/{directory}/ renders the current directory through the same theme used for static builds. Native ?page=2 links work without JavaScript. /listing?path=docs&offset=0&limit=100 returns public records after sorting the complete directory. /__dirwell/listing/manifest, /__dirwell/listing/block, /__dirwell/page and /__dirwell/asset support framework clients. Prefix every route with mountPath when configured.

The default HTML page size is 100 for pagination-capable themes. Live data defaults to one complete block because official rich clients need all entries for directory-wide search/sort. Set blockSize or an explicit listing policy to split responses; each block still reads the directory. listing accepts the same fixed or synchronous per-directory policy as core; operation identifies server, while mode: 'ssg' describes directory-oriented layout. JSON /listing defaults to 100 records and caps requests at 1,000, configurable through pageSize and maxPageSize.

Live blocks carry a public projection revision. If a requested revision has changed, the endpoint returns 410; the core browser loader retries once with a fresh manifest. Historical snapshots are not retained. Archive search is currently unavailable in live server mode; directory search remains available in rich themes.

File transport

Integrated handlers disable file transport by default. @dirwell/server/node exports startExplorerServer, which defaults to loopback, an ephemeral port and files: 'media'.

Media mode previews PNG/JPEG/GIF/WebP/AVIF and supported audio/video inline. HTML, SVG and other files download with Content-Disposition: attachment and X-Content-Type-Options: nosniff. files: 'attachment' downloads everything; files: 'inline' is an explicit host override. fileHref delegates valid file links to a host.

File responses stream with backpressure and cancellation. GET supports a single byte range; HEAD returns metadata and ignores Range, following HTTP semantics. ETag validators run after authorization. Broken/outside/excluded links expose only their declared target text, never outside-root bytes.

Headers, authorization and live updates

Successful responses default to Cache-Control: no-store and computed ETags. headers(request) customizes headers. Authorized responses require private caching and reject public/s-maxage policies. Host cache policies must account for identity variants and their desired freshness; a browser cache can avoid a network request entirely.

authorize(request, logicalPath) is request-level access control, not row-level redaction. Both the requested path and its canonical target are checked, including nested directory aliases. Checks precede directory child reads, file byte transfer and conditional responses. Allowing a parent listing exposes its selected child names; scope the root and filters accordingly.

live is opt-in. SSE notifications share one poll per canonical directory, recheck each subscriber's authorization, coalesce backpressured clients to the newest revision, send heartbeats and stop when the last subscriber leaves. The default interval is 1 second, minimum 25 ms; the default limit is 32 connections. Notifications identify public fact changes, not a replayable filesystem event log or the exact manifest revision. Svelte/Vue clients fetch fresh complete data and commit an update without resetting the current search or disabling its input.

There is no shared HTTP response/snapshot cache, filesystem watcher, distributed invalidation or transactional filesystem snapshot. Roots are assumed to be trusted local filesystems; hostile concurrent filesystem mutation and production-scale performance are not qualified. Stopping the Node server closes active connections as well as idle ones.

Host integrations

  • @dirwell/server/express: await createExpressMiddleware(options), mounted with app.use('/downloads', middleware) and matching mountPath. It preserves Express's original URL.
  • @dirwell/server/fastify: app.register(await createFastifyPlugin(options)). The plugin owns its route tree and uses Fastify hijack, so response hooks such as onSend do not decorate its raw response; use Dirwell's header hook.
  • Hono: app.all('/downloads/*', context => handler(context.req.raw)) forwards its real Request directly.
  • @dirwell/server/node: createNodeRequestListener integrates an existing Node HTTP server; the host owns shutdown.

Express 5, Fastify 5 and Hono 4 have executed integration tests. Fetch compatibility alone does not qualify other framework adapters or Edge runtimes; this package requires Node filesystem access.

Stable runtime validation

Handler configuration rejects unknown keys, invalid callbacks and malformed listing/live options before filesystem initialization. Sort and selection use Core's validated directory-service contract. The standalone Node helper separately checks host and integer port (0–65535) before opening a socket; those transport fields are not passed to Core or the Fetch handler. Custom theme objects remain extensible while their known render/hooks/listing contract is checked. These controls are included in 0.0.1.

The 0.0.x API may evolve. Pin your qualified version and upgrade the official family together. See support and verification for host, browser and device boundaries.

Bounded live archive search (0.0.2)

Set search: {} on the handler or Node server to enable GET /__dirwell/search?q=report&path=docs&limit=25. It searches normalized, case-insensitive logical names/paths, not file contents or annotations. path optionally limits results to a subtree. The same settings work under server.search in CLI configuration. Search is off by default; Ledger and Crosswave expose it when enabled. Their archiveSearch: false factory option hides that UI.

Defaults are 10,000 enumerated entries, 1,000 opened directories, two active requests, 100 results, a 5-second scan timeout and a 2-second open-dialog refresh interval. Customize maxEntries, maxDirectories, maxConcurrent, maxResults, timeoutMs, or refreshIntervalMs (at least 1,000 ms); maxResults is capped at 10,000. Fresh scans obey include/exclude/ignore rules and request authorization before entering children. Canonical physical entries appear once; symbolic-link aliases are omitted. Roots/ancestors must be authorized even for subtree queries. Use trusted local roots and bounded, cancellation-aware host callbacks.

Responses contain { version: 1, query, path, results: [{ name, path, kind, href }], truncated }, with native encoded links and null for host-owned file links when no transport is configured. Results are ordered by logical path. Result truncation is explicit; exhausted scan/time budgets return 503 without partial results, concurrent overload returns 429, invalid queries return 400 and denied query roots return 403. Each request rereads the filesystem and uses no-store; it is not a transactional snapshot or a distributed index/cache. The rich UI debounces typing by 300 ms and refreshes while its dialog is visible. Measure your host's filters, authorization latency and tree size before raising limits.

Directory URLs

Version 0.0.3 uses Core routing: { directoryUrls: "explicit" } by default for every theme. Choose slash for directory-index hosts or clean for a qualified extensionless host. Themes do not rewrite links. Existing source homepages and download names are preserved; output conflicts fail. CLI config puts routing at the top level, and --directory-urls overrides it. See directory URL guidance for output placement, host requirements, native Plain file navigation and migration.