DenoHttpServer unstable
Native Deno implementation of the Effect HttpServer.
Deno.serve can only upgrade requests to WebSocket, so other HTTP/1.1
upgrades fail. Serve them with NodeHttpServer from
@effect/platform-node, which runs on Deno's node:http.
Over HTTP/1.1, Deno.serve can stop delivering the request body once the
handler has returned a streamed response, so a handler that streams its
response while still reading the request payload can stall
(denoland/deno#36966).
Deno.serve negotiates HTTP/2 on its own: over TLS with browsers, and in
cleartext with clients that request it. Deno 2.8.3 to 2.9.2 panic and exit
when an HTTP/2 client cancels a request while its handler is still running
(denoland/deno#36053), so this package requires Deno 2.9.3 or newer.
Constructors
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
Provides a native Deno HTTP server together with Deno HTTP services.
Signature
declare function layer(options: any): Layer<HttpPlatform | Generator | DenoServices | HttpServer, ServeError>layerConfig
unstableCreates 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>layerHttpServices
unstableProvides Deno HTTP platform services and the standard Deno service set.
Signature
declare const layerHttpServices: Layer.Layer<HttpPlatform | Etag.Generator | DenoServices.DenoServices>layerServer
unstableProvides 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
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">