Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/twlite/node.serve
A dead simple http server for node
https://github.com/twlite/node.serve
Last synced: about 1 month ago
JSON representation
A dead simple http server for node
- Host: GitHub
- URL: https://github.com/twlite/node.serve
- Owner: twlite
- License: mit
- Created: 2023-11-12T11:12:40.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-12T11:14:02.000Z (about 1 year ago)
- Last Synced: 2024-09-20T00:27:44.969Z (about 2 months ago)
- Language: TypeScript
- Homepage: https://npm.im/serve.node
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `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
```sh
$ npm i serve.node
```# Documentation
This project was created by taking references from [Deno.serve (v1.38.1)](https://deno.land/[email protected]?s=Deno.serve) api documentation.
Therefore, things should work similarly.# Example
Run the following code:
```js
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:
```js
const res = await fetch('http://localhost:8000');
const body = await res.text();console.log(body); // 'Hello World'
```