import { withWeb } from "https://deno.land/x/ayonli_jsext@v0.9.72/http/internal.ts";
Creates a Node.js HTTP request listener with modern Web APIs.
NOTE: This function is only available in Node.js and requires Node.js v18.4.1 or above.
Examples
Example 1
Example 1
import * as http from "node:http";
import { withWeb } from "@ayonli/jsext/http/internal";
const server = http.createServer(withWeb(async (req) => {
return new Response("Hello, World!");
}));
server.listen(8000);
Parameters
listener: (req: Request, info: { remoteAddress: NetAddress; }) => Response | Promise<Response>
Returns
(req: IncomingMessage | Http2ServerRequest, res: ServerResponse | Http2ServerResponse) => void