@xtandard/kit/server — the HTTP side of a panel: createPanelHandler
(healthcheck, API, OpenAPI, static UI, SPA fallback, CORS, close()), the
index.html renderer, base-path and CORS helpers, and the plumbing for
product API routers (json, error, match, intParam, mapError,
authenticate with the scoped-token short-circuit, authorize).
node:fs is only loaded when static files are served, so the panel API
runs on Workers too.
Authorize an authenticated request. A scoped principal is decided by scope alone — the host’s provider is not consulted (defence in depth: a permissive host policy can’t widen a token).
A PanelTask that runs run every every (a Duration). The timer is unref()ed so it never keeps the process alive; a run that rejects is reported, never thrown. every <= 0 makes a task that does nothing.
Match pattern (with :name segments) against path; returns the decoded params, or null. A malformed % escape is no match (404), never a thrown URIError (500).
Locate a product’s built SPA. Pass the product module’s import.meta.url: compiled (the npm-consumer case) the bundle is the sibling ./ui of the module’s dist/ chunk; run from TypeScript source (examples, file: links) it is <repo>/dist/ui. Falls back to the compiled-layout path so the “build the UI” hint still fires when nothing is built yet.
Try to serve path (base-path-stripped, leading /) as a static file from uiDir. Returns a Response, or null if the file does not exist or the path escapes uiDir. Files under assets/ (content-hashed by the bundler) are cached for a year; everything else is no-cache.
Strip the (normalized) base path from a pathname. Returns a path that always starts with /. If the pathname does not start with the base path it is returned unchanged (the host framework may already have stripped the mount).