Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/billiegoose/lightning-http
pure JavaScript HTTP client/server
https://github.com/billiegoose/lightning-http
Last synced: 17 days ago
JSON representation
pure JavaScript HTTP client/server
- Host: GitHub
- URL: https://github.com/billiegoose/lightning-http
- Owner: billiegoose
- License: mit
- Created: 2020-03-08T02:57:24.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-12T04:32:35.000Z (about 2 years ago)
- Last Synced: 2024-10-06T03:23:25.981Z (3 months ago)
- Language: JavaScript
- Size: 145 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Goal: Recreate an "Express" like framework using only:
1. the "http.request" API described here: https://isomorphic-git.org/docs/en/http#implementing-your-own-http-client
2. the Node "net" moduleRationale: This closely approximates what would be required to do git HTTP requests over a pure WebRTC stream
# Usage
1. start the server: `npm start`
2. in another terminal, run `node client.js`The HTTP server should echo the response, but capitalized.
3. In a browser, navigate to http://localhost:8081/hello.html
The HTTP server should serve an HTML page (represented as an array of Uint8Arrays in `server.js`), and a favicon image (represented as an async iterable stream via `fs.createReadStream` in Node.js >= 10).
4. In a browser (or with cURL or whatever) open http://localhost:8081/hello/foobar
The HTTP server should return a text/plain message 'Hello, foobar!' to demonstrate that parsing and matching against path parameters in routes works.
# About
A streaming parser means the data can be chopped arbitrarily in the transport layer.
A high-level async iterable API is exposed that is converted seamlessly to HTTP/1.1 chunked transfer-encoding to provide streaming control at the application layer.
An Express-like route registration API simplifies writing servers. Hopefully it can be quickly adapted to work over WebRTC and to work inside Service Workers.