class HTTPServer

Minimal HTTP + WebSocket server used to serve test bundles and push reload events.

Constructors

HTTPServer()

Static Methods

serve(
config?: { port: number; onListen?: (s: object) => void; onError?: (e: Error) => void; },
handler: (
req: http.IncomingMessage,
res: http.ServerResponse
) => void
): Promise<http.Server>

Creates and starts a plain http.createServer instance on the given port.

Properties

_server: http.Server

Underlying Node.js HTTP server instance.

Registered middleware functions, applied in order before each route handler.

routes: Record<string, Record<string, Route>>

Registered routes keyed by HTTP method then path.

wss: WebSocketServer

WebSocket server attached to the HTTP server for live-reload broadcasts.

Methods

close(): Promise<void>

Closes the underlying HTTP server and all active connections, returning a Promise that resolves once the server is fully closed.

delete(
path: string,
handler: RouteHandler
): void

Registers a DELETE route handler.

get(
path: string,
handler: RouteHandler
): void

Registers a GET route handler.

listen(
port?: number,
callback?: () => void
): Promise<void>

Starts listening on the given port (0 = OS-assigned).

post(
path: string,
handler: RouteHandler
): void

Registers a POST route handler.

publish(data: string): void

Broadcasts a message to all connected WebSocket clients.

put(
path: string,
handler: RouteHandler
): void

Registers a PUT route handler.

use(middleware: Middleware): void

Adds a middleware function to the chain.