Getting started
srvx provides a unified standard API to create HTTP servers based on the standard web platform primitives (fetch, Request and Response) and works seamlessly with Deno, Bun and Node.js.
For Deno and Bun srvx unifies interface with zero overhead and for Node.js, creates a lightweight compatibility layer to wrap node:IncomingMessage as a standard Request object and convert final state of node:ServerResponse to a standard Response object.
Quick start
A server can be started using serve
function from srvx
package.
import { serve } from "srvx";
const server = serve({
fetch(request) {
return new Response("๐ Hello there!");
},
});
await server.ready();
console.log(`๐ Server ready at ${server.url}`);