Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kjartanhr/ts-tcp-httpserver
Simple HTTP/1.1 server written in TypeScript using node:net
https://github.com/kjartanhr/ts-tcp-httpserver
Last synced: 12 days ago
JSON representation
Simple HTTP/1.1 server written in TypeScript using node:net
- Host: GitHub
- URL: https://github.com/kjartanhr/ts-tcp-httpserver
- Owner: kjartanhr
- License: mit
- Created: 2023-11-25T01:50:34.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2023-11-25T02:03:42.000Z (12 months ago)
- Last Synced: 2023-11-26T02:30:19.289Z (12 months ago)
- Language: TypeScript
- Size: 202 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ts-tcp-httpserver
## What is this
This is an _extremely_ simple HTTP/1.1 server written in TypeScript using node:net to open a TCP socket to listen for and respond to HTTP requests.
## Goals
- [x] Receive and respond to HTTP requests purely by reading and writing data to and from a TCP socket.
- [x] With the above, support transmission of non-text formats (e.g. images, binaries, etc.)
- [ ] Use tests on a finished codebase to effectively test whether code behaviour stays consistent with feature changes.
- [x] Implement 'quality of life' features such as index pages at the root and in directories.
- [x] Code in a mostly functional+procedural style, avoiding nesting, and emphasising readable code.## What I've learned
- More about how HTTP/1.1 works as a standard in practical terms.
- Expanded knowledge of how to work with sockets as well as how they work.
- Expanded knowledge of buffers in nodejs, how they work and how to work with them.
- Using hexdump to diagnose problems in data transmission by examining data before and after being transmitted.## Running
- `yarn dev` will run `tsc` in watch mode concurrently with `nodemon` to restart the server when changes are made.
- `yarn build` will run `tsc` to compile to the `build/` directory.
- `yarn start` will run `tsc` to compile to the `build/` directory and immediately run the built server.