<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 function wsServer<A, E, R>(serve: Layer.Layer<A, E, R>, options?: HttpServerOptions): Layer.Layer<A, E, R | HttpServer.HttpServer> (+2 overloads)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 })),
);
wsServer<function (type parameter) A in wsServer<A, E, R>(serve: Layer.Layer<A, E, R>, options?: HttpServerOptions): Layer.Layer<A, E, R | HttpServer.HttpServer>A, function (type parameter) E in wsServer<A, E, R>(serve: Layer.Layer<A, E, R>, options?: HttpServerOptions): Layer.Layer<A, E, R | HttpServer.HttpServer>E, function (type parameter) R in wsServer<A, E, R>(serve: Layer.Layer<A, E, R>, options?: HttpServerOptions): Layer.Layer<A, E, R | HttpServer.HttpServer>R>(
serve: Layer.Layer<A, E, R>(parameter) serve: {
build: (memoMap: MemoMap, scope: Scope.Scope) => Effect<Context.Context<A>, E, R>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
serve: import LayerLayer.interface Layer<in ROut, out E = never, out RIn = never>A Layer describes how to build one or more services for dependency injection.
When to use
Use to model construction of application services for dependency injection,
especially when services have dependencies, can fail during construction, or
need scoped setup and release.
Details
A Layer<ROut, E, RIn> represents ROut as the services this layer
provides, E as the possible errors during layer construction, and RIn as
the services this layer requires as dependencies.
Layer<function (type parameter) A in wsServer<A, E, R>(serve: Layer.Layer<A, E, R>, options?: HttpServerOptions): Layer.Layer<A, E, R | HttpServer.HttpServer>A, function (type parameter) E in wsServer<A, E, R>(serve: Layer.Layer<A, E, R>, options?: HttpServerOptions): Layer.Layer<A, E, R | HttpServer.HttpServer>E, function (type parameter) R in wsServer<A, E, R>(serve: Layer.Layer<A, E, R>, options?: HttpServerOptions): Layer.Layer<A, E, R | HttpServer.HttpServer>R>,
options: HttpServerOptionsoptions?: HttpServerOptions,
): import LayerLayer.interface Layer<in ROut, out E = never, out RIn = never>A Layer describes how to build one or more services for dependency injection.
When to use
Use to model construction of application services for dependency injection,
especially when services have dependencies, can fail during construction, or
need scoped setup and release.
Details
A Layer<ROut, E, RIn> represents ROut as the services this layer
provides, E as the possible errors during layer construction, and RIn as
the services this layer requires as dependencies.
Layer<function (type parameter) A in wsServer<A, E, R>(serve: Layer.Layer<A, E, R>, options?: HttpServerOptions): Layer.Layer<A, E, R | HttpServer.HttpServer>A, function (type parameter) E in wsServer<A, E, R>(serve: Layer.Layer<A, E, R>, options?: HttpServerOptions): Layer.Layer<A, E, R | HttpServer.HttpServer>E, function (type parameter) R in wsServer<A, E, R>(serve: Layer.Layer<A, E, R>, options?: HttpServerOptions): Layer.Layer<A, E, R | HttpServer.HttpServer>R | import HttpServerHttpServer.class HttpServerclass HttpServer {
key: Identifier;
Service: {
serve: { <E, R>(effect: Effect.Effect<HttpServerResponse, E, R>): Effect.Effect<void, never, Exclude<R, HttpServerRequest> | Scope.Scope>; <E, R, App extends Effect.Effect<HttpServerResponse, any, any>>(effect: Effect.Effect<HttpServerResponse, E…;
address: Address;
};
}
Service tag for an HTTP server runtime.
Details
The service can serve an HTTP response effect and exposes the address where the
server is listening.
HttpServer>;
export function function wsServer(options?: HttpServerOptions): Layer.Layer<never, never, Hyperlink.ServedHyperServices | HttpServer.HttpServer> (+2 overloads)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 })),
);
wsServer(
options: HttpServerOptionsoptions?: HttpServerOptions,
): import LayerLayer.interface Layer<in ROut, out E = never, out RIn = never>A Layer describes how to build one or more services for dependency injection.
When to use
Use to model construction of application services for dependency injection,
especially when services have dependencies, can fail during construction, or
need scoped setup and release.
Details
A Layer<ROut, E, RIn> represents ROut as the services this layer
provides, E as the possible errors during layer construction, and RIn as
the services this layer requires as dependencies.
Layer<never, never, import HyperlinkHyperlink.class ServedHyperServicesclass ServedHyperServices {
key: Identifier;
Service: {
register: (entry: ServedHyperlink) => Effect.Effect<void>;
all: Effect.Effect<ReadonlyArray<ServedHyperlink>>;
};
}
The served-HyperServices registry — an accumulator
serve
appends to and
httpServer
reads.
A plain Ref-backed list (not type-level state), so many serve layers compose under Layer.mergeAll
and the server sees every one. Provided by
httpServer
(or
servedHyperServicesLayer
); serve
registers only if it's present (so serve also works standalone).
ServedHyperServices | import HttpServerHttpServer.class HttpServerclass HttpServer {
key: Identifier;
Service: {
serve: { <E, R>(effect: Effect.Effect<HttpServerResponse, E, R>): Effect.Effect<void, never, Exclude<R, HttpServerRequest> | Scope.Scope>; <E, R, App extends Effect.Effect<HttpServerResponse, any, any>>(effect: Effect.Effect<HttpServerResponse, E…;
address: Address;
};
}
Service tag for an HTTP server runtime.
Details
The service can serve an HTTP response effect and exposes the address where the
server is listening.
HttpServer>;
export function 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> (+2 overloads)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 })),
);
wsServer<const function (type parameter) Serves in 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>Serves extends type ServerServeList = readonly [Layer.Any, ...Layer.Any[]]Non-empty serve list — open E/R so heterogeneous HyperService deps remain expressible.
ServerServeList>(
serves: const Serves extends ServerServeListserves: function (type parameter) Serves in 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>Serves,
options: HttpServerOptionsoptions?: HttpServerOptions,
): import LayerLayer.interface Layer<in ROut, out E = never, out RIn = never>A Layer describes how to build one or more services for dependency injection.
When to use
Use to model construction of application services for dependency injection,
especially when services have dependencies, can fail during construction, or
need scoped setup and release.
Details
A Layer<ROut, E, RIn> represents ROut as the services this layer
provides, E as the possible errors during layer construction, and RIn as
the services this layer requires as dependencies.
Layer<
import LayerLayer.type Success<T extends Layer.Any> =
T extends Layer.Layer<
infer _ROut,
infer _E,
infer _RIn
>
? _ROut
: never
Extracts the service output type (ROut) from a Layer type.
When to use
Use to derive the services provided by an existing or generic Layer without
restating its ROut type parameter.
Success<function (type parameter) Serves in 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>Serves[number]>,
import LayerLayer.type Error<T extends Layer.Any> =
T extends Layer.Layer<
infer _ROut,
infer _E,
infer _RIn
>
? _E
: never
Extracts the error type (E) from a Layer type.
When to use
Use to derive a layer construction error type for helper types, wrappers, or
APIs that preserve a layer failure channel.
Error<function (type parameter) Serves in 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>Serves[number]>,
import LayerLayer.type Services<T extends Layer.Any> =
T extends infer L
? L extends Layer.Layer<
infer _ROut,
infer _E,
infer _RIn
>
? _RIn
: never
: never
Extracts the service requirements (RIn) from a Layer type.
When to use
Use to derive the dependency requirements of a generic or inferred Layer
without restating its RIn type parameter.
Services<function (type parameter) Serves in 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>Serves[number]> | import HttpServerHttpServer.class HttpServerclass HttpServer {
key: Identifier;
Service: {
serve: { <E, R>(effect: Effect.Effect<HttpServerResponse, E, R>): Effect.Effect<void, never, Exclude<R, HttpServerRequest> | Scope.Scope>; <E, R, App extends Effect.Effect<HttpServerResponse, any, any>>(effect: Effect.Effect<HttpServerResponse, E…;
address: Address;
};
}
Service tag for an HTTP server runtime.
Details
The service can serve an HTTP response effect and exposes the address where the
server is listening.
HttpServer
>;
export function function wsServer<A, E, R>(serve: Layer.Layer<A, E, R>, options?: HttpServerOptions): Layer.Layer<A, E, R | HttpServer.HttpServer> (+2 overloads)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 })),
);
wsServer(
servesOrOptions: | ServerServeLayer
| ServerServeList
| HttpServerOptions
servesOrOptions?: type ServerServeLayer = Layer.AnyOne serve layer accepted by
httpServer
/
wsServer
/
ipcServer
.
ServerServeLayer | type ServerServeList = readonly [Layer.Any, ...Layer.Any[]]Non-empty serve list — open E/R so heterogeneous HyperService deps remain expressible.
ServerServeList | HttpServerOptions,
maybeOptions: HttpServerOptionsmaybeOptions?: HttpServerOptions,
): import LayerLayer.Any {
return function serverImpl(
serverProtocol: ServerProtocol,
serverKind: ProtocolKind,
servesOrOptions?:
| ServerServeLayer
| ServerServeList
| HttpServerOptions,
maybeOptions?: HttpServerOptions
): Layer.Any
serverImpl(
import HyperlinkHyperlink.const serverProtocolWebsocket: (
path?: HttpRouter.PathInput
) => Layer.Layer<
RpcServer.Protocol,
never,
| RpcSerialization.RpcSerialization
| HttpRouter.HttpRouter
>
serverProtocolWebsocket,
"WebSocket",
servesOrOptions: | ServerServeLayer
| ServerServeList
| HttpServerOptions
servesOrOptions,
maybeOptions: HttpServerOptionsmaybeOptions,
);
}