Files
codingetandClaude f659f230cd
CI / lint (pull_request) Successful in 3m39s
CI / format (pull_request) Successful in 3m24s
CI / install (pull_request) Successful in 9m4s
CI / typetest (pull_request) Successful in 3m5s
CI / typecheck (pull_request) Successful in 3m20s
CI / node-tests (pull_request) Successful in 3m31s
CI / browser-tests (pull_request) Successful in 5m16s
docs: add per-package READMEs and position Tailshare as the flagship app
Give every workspace a README describing what it does, its entry points,
and a short usage example, and link them from the root package table.

Frame Tailshare in the root README as the application the libraries exist
to be composed into, with the other apps as development and testing
surfaces. Its own README records what works today and what the open
issues intend for it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-14 23:51:59 +00:00
..

@webnet/http-static

Static file HTTP handler backed by an @webnet/vfs AsyncVFS.

createStaticHandler turns an AsyncVFS into a @webnet/http Handler: it resolves request paths against the VFS, serves files with ETag/Last-Modified conditional requests and Range support, and can render directory listings (HTML or JSON, based on Accept) or fall back to a single file (e.g. an SPA's index.html) when nothing matches.

Usage

import { createStaticHandler } from "@webnet/http-static"
import { Server } from "@webnet/http/server"
import type { AsyncVFS } from "@webnet/vfs"
import type { RawListener } from "@webnet/transport"

declare const vfs: AsyncVFS
declare const listener: RawListener

const handler = createStaticHandler(vfs, {
  prefix: "/static",
  index: ["index.html"],
  fallback: "/index.html",
})

const server = new Server(handler)
await server.listen(listener)

See also

  • @webnet/httpHandler/Server this package's output is used with
  • @webnet/vfs — the AsyncVFS interface this package serves
  • @webnet/webdav — a read/write, protocol-level alternative to serving a VFS statically