The configuration options for the web server.
Configuration options for the web server.
A callback function to handle fetch requests.
Optional
port?: numberThe port number on which the server will listen. Defaults to 0 if not specified.
A promise that resolves to an object containing the created server instance and its address information.
const { server } = await createWebServer({
port: 9000,
fetchCallback: (ctx) => {
if (ctx.method === 'GET' && ctx.path('/')) {
return new Response('OK');
}
return new Response();
}
});
Creates and starts an HTTP web server on the specified port.