Function toNodeListener
-
toNodeListener(
handler: FetchHandler,
options?: NodeListenerOptions,
): (
req: IncomingMessage,
res: ServerResponse,
next?: (error?: unknown) => void,
) => Promise<void>Parameters
- handler: FetchHandler
- options: NodeListenerOptions = {}
Returns (
req: IncomingMessage,
res: ServerResponse,
next?: (error?: unknown) => void,
) => Promise<void>
Bridges
node:httpto a Fetch handler, with no dependency. The result is also an Express middleware: when the handler returnsundefinedand anextcallback exists it is called, otherwise the reply is a 404. A handler that throws gets a 500 (or the socket is destroyed if headers are already out).