Hyperlinkv0.9.0-beta.0

Node

<A, E, R>(
  serve: Layer.Layer<A, E, R>,
  options?: HttpServerOptions
): Layer.Layer<A, E, R | HttpServer.HttpServer>
(options?: HttpServerOptions): Layer.Layer<
  never,
  never,
  Hyperlink.ServedHyperServices | HttpServer.HttpServer
>
<const Serves extends ServerServeList>(
  serves: Serves,
  options?: HttpServerOptions
): Layer.Layer<
  Layer.Success<Serves[number]>,
  Layer.Error<Serves[number]>,
  Layer.Services<Serves[number]> | HttpServer.HttpServer
>

A WebSocket RPC server — the httpServer sibling for the browser. Everything a client subscribes to (each HyperService's status + metrics + logs) rides one multiplexed WebSocket per client, so a dashboard never trips the browser's ~6-connection-per-origin HTTP/1.1 cap that starves streams over plain HTTP. Identical to httpServer in every other way — same serve list, same options, same /health — it just speaks WebSocket instead of HTTP POST. Clients connect with Hyperlink.ws (or Hyperlink.layerProtocol(Hyperlink.protocolWebsocket())); a fleet whose peers also serve over this should add Hyperlink.layerPeerProtocol(Hyperlink.protocolWebsocket).

const Node = Hyperlink.wsServer([Hyperlink.serve(Jobs, jobsImpl)]).pipe(
  Layer.provide(NodeHttpServer.layer(() => createServer(), { port })),
);
export function wsServer<A, E, R>(
  serve: Layer.Layer<A, E, R>,
  options?: HttpServerOptions,
): Layer.Layer<A, E, R | HttpServer.HttpServer>;
export function wsServer(
  options?: HttpServerOptions,
): Layer.Layer<never, never, Hyperlink.ServedHyperServices | HttpServer.HttpServer>;
export function wsServer<const Serves extends ServerServeList>(
  serves: Serves,
  options?: HttpServerOptions,
): Layer.Layer<
  Layer.Success<Serves[number]>,
  Layer.Error<Serves[number]>,
  Layer.Services<Serves[number]> | HttpServer.HttpServer
>;
export function wsServer(
  servesOrOptions?: ServerServeLayer | ServerServeList | HttpServerOptions,
  maybeOptions?: HttpServerOptions,
): Layer.Any {
  return serverImpl(
    Hyperlink.serverProtocolWebsocket,
    "WebSocket",
    servesOrOptions,
    maybeOptions,
  );
}