Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/workerd/http.ts>withWeb

A JavaScript extension package for building strong and modern applications.
Latest
function withWeb
Re-export
import { withWeb } from "https://deno.land/x/ayonli_jsext@v0.9.72/workerd/http.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

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