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
Create an HTTP server using the serve
function from srvx
package.
server.mjs
import { serve } from "srvx";
const server = serve({
fetch(request) {
return new Response("👋 Hello there!");
},
});
await server.ready();
console.log(`🚀 Server ready at ${server.url}`);
Install srvx
as a dependency:
npm i srvx
Then, run the server using your favorite runtime:
node server.mjs