Skip to content
Effect 4.0 is here. One ecosystem. Zero dependencies.

DenoHttpServer unstable

Native Deno implementation of the Effect HttpServer.

7 exports Since v4.0.0 Source

Constructors

make

unstable
Since v4.0.0

Creates a scoped native Deno HTTP server.

Signature

declare const make: (...args: [options: any]) => Effect<{
readonly address: SocketAddress;
readonly serve: {
<E, R>(effect: Effect<HttpServerResponse, E, R>): Effect<void, never, Scope | Exclude<R, HttpServerRequest>>;
<E, R, App extends Effect<HttpServerResponse, any, any>>(effect: Effect<HttpServerResponse, E, R>, middleware: Applied<App, E, R>): Effect<void, never, Scope | Exclude<R, HttpServerRequest>>;
};
}, ServeError, Scope>

Layers

layer

unstable
Since v4.0.0

Provides a native Deno HTTP server together with Deno HTTP services.

Signature

declare function layer(options: any): Layer<HttpPlatform | Generator | DenoServices | HttpServer, ServeError>

layerConfig

unstable
Since v4.0.0

Creates the Deno HTTP server and support-services layer from configurable options.

Signature

declare function layerConfig(options: Config<any>): Layer<Path | HttpPlatform | Generator | FileSystem | HttpServer, ServeError | ConfigError>
Since v4.0.0

Provides Deno HTTP platform services and the standard Deno service set.

Signature

declare const layerHttpServices: Layer.Layer<HttpPlatform | Etag.Generator | DenoServices.DenoServices>

layerServer

unstable
Since v4.0.0

Provides only the native Deno HTTP server.

Signature

declare const layerServer: (options: ServeOptions & {
readonly disablePreemptiveShutdown?: boolean;
readonly gracefulShutdownTimeout?: Duration.Input;
readonly websocket?: Deno.UpgradeWebSocketOptions;
}) => Layer.Layer<Server.HttpServer, Error.ServeError>

Options

ServeOptions

type unstable
Since v4.0.0

Native Deno TCP, TLS, or Unix serve options managed by the scoped server.

Details

signal and onError are omitted because the scope and Effect HTTP handler own server and failure lifecycles. Server constructors additionally accept WebSocket settings that apply to every upgrade; protocol therefore cannot vary per request.

Signature

type ServeOptions = Omit<Deno.ServeTcpOptions, "signal" | "onError"> & Partial<Deno.TlsCertifiedKeyPem> | Omit<Deno.ServeUnixOptions, "signal" | "onError">

Testing

layerTest

unstable
Since v4.0.0

Starts a Deno HTTP server on an ephemeral loopback port for tests.

Signature

declare const layerTest: Layer.Layer<Server.HttpServer | HttpPlatform | FileSystem.FileSystem | Etag.Generator | Path.Path | HttpClient>