Minimal HTTP + WebSocket server used to serve test bundles and push reload events.
-
_server: http.Server
Underlying Node.js HTTP server instance.
-
close(): Promise<void>
Closes the underlying HTTP server and all active connections, returning a Promise that resolves once the server is fully closed.
-
delete(): voidpath: string,handler: RouteHandler
Registers a DELETE route handler.
-
get(): voidpath: string,handler: RouteHandler
Registers a GET route handler.
-
listen(): Promise<void>port?: number,callback?: () => void
Starts listening on the given port (0 = OS-assigned).
-
middleware: Middleware[]
Registered middleware functions, applied in order before each route handler.
-
post(): voidpath: string,handler: RouteHandler
Registers a POST route handler.
-
publish(data: string): void
Broadcasts a message to all connected WebSocket clients.
-
put(): voidpath: string,handler: RouteHandler
Registers a PUT route handler.
-
routes: Record<string, Record<string, Route>>
Registered routes keyed by HTTP method then path.
-
serve(): Promise<http.Server>config?: { port: number; onListen?: (s: object) => void; onError?: (e: Error) => void; },handler: () => voidreq: http.IncomingMessage,res: http.ServerResponse
Creates and starts a plain
http.createServerinstance on the given port. -
use(middleware: Middleware): void
Adds a middleware function to the chain.
-
wss: WebSocketServer
WebSocket server attached to the HTTP server for live-reload broadcasts.
Middleware function signature — call next() to continue the chain.
Route handler function signature for registered GET/POST/etc. routes.
Map of file extensions to their corresponding MIME type strings.
Usage
import * as mod from "lib/servers/http.ts";