serve (@shadow-js/dusk/bun)
Serves a handler with Bun.serve.
Serves a handler with Bun.serve.
Import#
ts
import { serve } from "@shadow-js/dusk/bun";
Signature#
ts
function serve(
handler: Handler,
options: NativeServeOptions = {},
): Promise<NativeServeHandle>
Parameters#
| Name | Description |
|---|---|
handler |
The fetch handler, usually handler from the server bundle. |
options |
Port, hostname, static folder, compression and shutdown. |
Returns#
The running server.
Throws#
- Error when the code does not run on Bun.
Examples#
ts
import { serve } from "@shadow-js/dusk/bun";
import { handler } from "./dist/server/entry.js";
await serve(handler, { static: "/srv/app/dist/client", hostname: "0.0.0.0" });