serve.node
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

Node.serve()

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.

Installation

$ npm i serve.node

Documentation

This project was created by taking references from Deno.serve (v1.38.1) api documentation. Therefore, things should work similarly.

Example

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'

Readme

Keywords

Package Sidebar

Install

npm i serve.node

Weekly Downloads

1

Version

0.0.2

License

ISC

Unpacked Size

36.4 kB

Total Files

6

Last publish

Collaborators

  • snowflake7