HTTP/1.1 server implemented in pure TypeScript to demystify how requests are parsed and handled over raw TCP sockets.
This project spins up a raw TCP listener with node:net, consumes socket data line-by-line, and validates HTTP/1.1 request lines without frameworks or third-party helpers.
It is built to spin up a web server in a low-memory device for homelab.
I needed a shared grocery list with my roommate, but every “simple” solution demanded a heavy server my 2GB RAM, 128GB HDD laptop couldn’t handle. After struggling with bloated stacks, I built a lightweight, low-memory grocery-list service that’s easy to self-host and stays fast on old hardware.
- Zero dependencies – everything relies on the Node.js standard library.
- Streaming parser – converts socket chunks to CRLF-delimited frames via async iterables.
- Type-safe internals – request and utility layers are strongly typed end-to-end.
- Composable primitives – the async queue can back any producer/consumer workflow.
- Node.js 20.x or newer
- npm 10.x (bundled with Node 20)
npm install
npm run buildnpm run start
curl -v http://localhost:42069/npm run start— build and run the server onlocalhost:42069npm run dev— rebuild and restart automatically while you editsrc/npm run build— emit compiled JavaScript intodist/
Quick test sequence:
npm run start
curl -v http://localhost:42069/AsyncQueue<T>bridges push-based producers with async iterators, making it reusable for sockets, file streams, or child processes.getLinesChannelaccumulates socket chunks until\r\n, yielding discrete lines without buffering an entire request.getRequestLinevalidates method, path, and protocol version early; malformed requests surface errors immediately.- ESLint is available (configure a script) and tests are TBD—consider adding unit coverage for the parser and queue.
- Fork the repository and create a feature branch.
- Run
npm run buildto ensure the TypeScript sources compile cleanly. - Open a pull request describing the change and any follow-up ideas.
- Parse header fields and request bodies.
- Respond with minimal HTTP status lines and payloads.
- Add routing utilities or middleware hooks.
- Improve error handling and graceful shutdowns.
- Introduce integration tests against the TCP socket.
