@hyperfrontend/features/serverServer
Dev server and debug UI for testing host/hostee interactions — per-app static hosting plus display-mode, resize, message-log, and security controls.
Quick start
Start a dev server from a resolved hf-dev.config.*:
import { resolveDevConfig, startDevServer } from '@hyperfrontend/features/server'
const config = await resolveDevConfig({ cwd: process.cwd(), flags })
const handle = await startDevServer(config)
console.log(handle.debugUrl) // http://localhost:4280/
handle.apps.forEach((app) => console.log(app.name, app.url))
await handle.close()
How it serves
Each configured app is served by its own static server bound to its port, so apps load at distinct origins — letting the host/hostee message channel and security envelope be exercised cross-origin, exactly as in production. The debug UI is hosted at / on a separate control server (default port 4280), which also exposes the running-app manifest at /__apps and the compiled debug-UI assets under /__debug/.
API
| Export | Purpose |
|---|---|
resolveDevConfig | Resolve hf-dev.config.* + CLI flags into concrete app servers. |
startDevServer | Start the app servers and the debug-UI control server. |
validateDevConfig / validateApps / validateDevApp | Runtime validation of the config shape. |
createStaticHandler / serveFile | Static-file request handling used by the app servers. |
The config schema (apps, debug) and the defineDevConfig() authoring helper live in the main @hyperfrontend/features entry.
API Reference
ƒ Functions
createStaticHandler(root: string, deps: StaticHandlerDeps): (req: IncomingMessage, res: ServerResponse) => void
Parameters
Returns
(req: IncomingMessage, res: ServerResponse) => voidhttp.createServer.Example
Serving a compiled app directory
const server = createServer(createStaticHandler('/abs/dist'))/ and dropping any query string.Parameters
| Name | Type | Description |
|---|---|---|
§url | string | The raw request URL ( req.url), which may be undefined. |
Returns
stringExample
Stripping a query string
requestPath('/app.js?v=2') // '/app.js'hf-dev.config.* into concrete app servers and debug settings, applying config file < flags precedence: --apps replaces the apps array, --port sets the debug-UI port, and --config selects the file.Parameters
| Name | Type | Description |
|---|---|---|
§options | ResolveDevConfigOptions | The working directory, parsed flags, and injectable deps. |
Returns
Promise<ResolvedDevConfig>Example
Resolving a discovered dev config
const resolved = await resolveDevConfig({ cwd: process.cwd(), flags })serveFile(root: string, urlPath: string, res: ServerResponse, deps: StaticHandlerDeps): void
root to the response, sending 403 on a traversal attempt and 404 when the file is missing.Parameters
Example
Serving an app's `index.html`
serveFile('/abs/dist', '/', res)Parameters
Returns
Promise<DevServerHandle>Example
Starting a dev server from a resolved config
const handle = await startDevServer(resolved)
console.log(handle.debugUrl)
await handle.close()Parameters
Returns
DevAppConfig[]Example
Validating an apps array loaded from `--apps`
const apps = validateApps([{ name: 'clock', outputDir: './dist' }], '/p/apps.json')name/outputDir strings and an optional numeric port.Parameters
Returns
DevAppConfigExample
Validating a single app entry
const app = validateDevApp({ name: 'clock', outputDir: './dist' }, 0, '/p/hf-dev.config.json')Parameters
Returns
DevConfigExample
Validating a loaded dev config
const config = validateDevConfig({ apps: [{ name: 'clock', outputDir: './dist' }] }, '/p/hf-dev.config.json')◈ Interfaces
hf-dev.config.*: concrete app servers plus debug settings.