Deno Runtime
Basic Usage
import { serve } from "@hornjs/fest";
import { DenoRuntimeAdapter } from "@hornjs/fest/deno";
serve({
adapter: new DenoRuntimeAdapter(),
routes: {
"/": () => new Response("Hello from Deno"),
},
fetch: () => new Response("Not Found", { status: 404 }),
});
Constructor Options
new DenoRuntimeAdapter(options) accepts DenoServerOptions, which is an alias
for Deno.ServeOptions.
At setup time, fest also merges in generic listener settings such as
hostname, port, reusePort, TLS certificate fields, and the server-level
error handler.
Commonly Used Options
signal: close the server when the signal abortsonError: customize how uncaught request errors become responsesonListen: observe the final listening address
The final listener options also include TCP fields handled by Deno.serve(),
such as hostname, port, and reusePort.
Official References
- Deno
ServeOptions: https://docs.deno.com/api/deno/~/Deno.ServeOptions - Deno
serve()API: https://docs.deno.com/api/deno/~/Deno.serve - Deno TCP serve options: https://docs.deno.com/api/deno/~/Deno.ServeTcpOptions
What the Adapter Does
DenoRuntimeAdapter converts generic ServerOptions into Deno.serve()
options and waits for Deno's onListen callback before resolving the final
server URL.
It is responsible for:
- resolving
hostnameandport - passing
reusePort - mapping
errortoonError - forwarding TLS certificate options
- exposing the resolved public URL through
server.url
Deno-Specific Options
Pass native Deno.ServeOptions to the adapter constructor:
import { DenoRuntimeAdapter } from "@hornjs/fest/deno";
const adapter = new DenoRuntimeAdapter({
signal: AbortSignal.timeout(30_000),
});
These values are merged with the generic server options during setup().
TLS
TLS works the same way as in other node-like adapters: cert and key may be
provided as PEM content or as file paths.
serve({
adapter: new DenoRuntimeAdapter(),
protocol: "https",
tls: {
cert: "./certs/dev-cert.pem",
key: "./certs/dev-key.pem",
},
routes: {
"/": () => new Response("secure"),
},
fetch: () => new Response("Not Found", { status: 404 }),
});
Listening Semantics
Unlike Node and Bun, Deno.serve() reports the bound address asynchronously
through onListen. The adapter caches that information and derives server.url
from it.
CLI Usage
You can run the package through Deno with npm compatibility:
deno run -A npm:@hornjs/fest
The current CLI --import flow is only for Node.js and Bun, so JSX / TSX entry
preloads should not rely on that flag under Deno.