Deno
Reference for the host exports in @streamsy/serve/deno. They provide a scoped Deno HTTP listener.
import * as Deno from "@streamsy/serve/deno";
import type { Duration, Effect, Layer } from "effect";
import type { Etag, HttpPlatform, HttpServer, HttpServerError } from "effect/http";
import type { FileSystem, Path, Stdio, Terminal } from "effect";
import type { ChildProcessSpawner } from "effect/process";Deno.listener is the HTTP listener Layer of a Streamsy host on Deno. Provide it to Serve.layer. See Run a process server and Clean shutdown.
Listener
Deno.listener
declare function listener(
options?: Deno.ListenerOptions,
): Layer.Layer<
| Etag.Generator
| HttpPlatform.HttpPlatform
| HttpServer.HttpServer
| ChildProcessSpawner.ChildProcessSpawner
| FileSystem.FileSystem
| Path.Path
| Stdio.Stdio
| Terminal.Terminal,
HttpServerError.ServeError,
never
>;
Deno.listener binds the port when its Layer builds, and closes the server when the scope of the Layer closes. When the bind fails, the Layer fails with HttpServerError.ServeError. The Layer requires no services.
The listener binds port 3000 on 127.0.0.1 unless the options set others. Without gracefulShutdownTimeout, the listener turns off the preemptive shutdown of the platform server, and its scope finalizer waits for in-flight requests to end. With gracefulShutdownTimeout, the platform server stops waiting after that time.
The Deno HTTP server has no idle or response timeout that cuts off a parked long poll or an SSE body.
Deno.nodeSqliteCompat
declare const nodeSqliteCompat: Effect.Effect<void, never, never>;
Deno.nodeSqliteCompat adds a no-op enableLoadExtension method to the node:sqlite DatabaseSync prototype when that method is absent. It leaves an existing method unchanged.
Run this Effect before the first SqliteClient.make from @effect/sql-sqlite-node. That driver calls enableLoadExtension(false) on each open, and on Deno that call throws without this method. When the import of node:sqlite fails, the Effect dies.
Options
Deno.ListenerOptions
interface ListenerOptions {
readonly port?: number;
readonly hostname?: string;
readonly gracefulShutdownTimeout?: Duration.Input;
}
Deno.ListenerOptions holds the options of Deno.listener.
| Field | Default | Meaning |
|---|---|---|
port | 3000 | The port to bind |
hostname | 127.0.0.1 | The address to bind |
gracefulShutdownTimeout | Unset | The longest wait for in-flight requests during shutdown |
Defaults
Deno.DEFAULT_PORT
declare const DEFAULT_PORT: 3000;
Deno.DEFAULT_PORT is the default port of Deno.listener: 3000.
Deno.DEFAULT_HOSTNAME
declare const DEFAULT_HOSTNAME: "127.0.0.1";
Deno.DEFAULT_HOSTNAME is the default bind address of Deno.listener: 127.0.0.1.