Skip to content

DenoHttpServer

Native Deno implementation of the Effect HttpServer.

7 exports Added in v4.0.0 Source

Constructors

make

Added in v4.0.0 Source

Creates a scoped native Deno HTTP server.

Signature

declare const make: (...args: [options: any]) => Effect<
{
readonly address: Address;
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>>;
};
},
never,
Scope
>;

Layers

layer

Added in v4.0.0 Source

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

Signature

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

layerConfig

Added in v4.0.0 Source

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, ConfigError>;

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

Signature

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

layerServer

Added in v4.0.0 Source

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>;

Options

ServeOptions type

Added in v4.0.0 Source

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

Added in v4.0.0 Source

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
>;