A minimal HTTP server built directly on top of TCP using Node.js and TypeScript.
This project is designed to demonstrate how HTTP works under the hood — without using http, Express, or any web framework.
- Raw TCP server using Node.js
netmodule - Manual HTTP request parsing
- Manual HTTP response serialization
- Simple built-in router
- Keep-alive support via a custom
ConnectionManager - Clean, readable, educational code
Most web developers use frameworks that hide the complexity of HTTP.
This project exists to demystify HTTP by showing:
- What an HTTP request really looks like
- How responses are constructed
- How connections are managed
- How servers handle multiple requests per connection
It’s intended for learning, experimentation, and deeper understanding — not production use.
simple-http-server/
├── src/
│ └── server.ts # Full TCP-based HTTP server implementation
├── package.json
├── tsconfig.json
└── README.md
- Node.js 18+
- npm
npm installnpm run devThe server will start on:
tcp://localhost:3000
You can test the server using curl:
# Root route
curl http://localhost:3000/
# Health check
curl http://localhost:3000/health
# Echo endpoint
curl -X POST http://localhost:3000/echo -d "Hello server"
- TCP sockets and network I/O
- HTTP request / response structure
- Buffers vs strings
- Event-driven architecture in Node.js
- Connection keep-alive logic
- Simple routing without frameworks
- Proper Content-Length body parsing
- Query string parsing
- Respect Connection: close header
- Request timeout handling
- HTTP/1.1 edge cases
- Logging and metrics
This repository accompanies a Medium article explaining the concepts step by step:
Demystifying HTTP: Building a Simple Web Server in TypeScript From Scratch
This project is for educational purposes only. It is not production-ready and should not be exposed to the public internet.
MIT License