This is a demo project that attempts to mirror partial Deno.serve()
api in Node.js.
I don't recommend this for production. It is fine to use for development and playing around.
If you are interested in making this project production ready, please let me know.
$ npm i serve.node
This project was created by taking references from Deno.serve (v1.38.1) api documentation. Therefore, things should work similarly.
Run the following code:
import { Node, Response } from 'serve.node';
Node.serve(() => new Response('Hello World'));
It spins up an http server on port 8000
by default.
You can then make a request to the server:
const res = await fetch('http://localhost:8000');
const body = await res.text();
console.log(body); // 'Hello World'