Waypoint is a small HTTP/1.1 framework built directly on Node.js net.
The assignment goal is to understand what a framework like Express is hiding: TCP sockets, text-based HTTP messages, routing, response formatting, and static asset serving. Waypoint keeps those parts visible while still giving the app developer a friendly API.
npm startThen open:
http://localhost:3000/http://localhost:3000/api/hello?name=Guyhttp://localhost:3000/static/style.csshttp://localhost:3000/__routes
npm testconst path = require("node:path");
const { createWaypoint } = require("./src/waypoint");
const app = createWaypoint({ name: "HW1 demo" });
app.static("/static", path.join(__dirname, "public"));
app.get("/api/hello")
.as("friendly greeting")
.handle((req, res) => {
res.json({ message: `Hello ${req.query.name || "there"}` });
});
app.post("/api/echo")
.as("JSON echo")
.handle((req, res) => {
res.status(201).json({ received: req.body });
});
app.explorer("/__routes");
app.listen(3000);- The server uses
net.createServer()and never imports Node'shttporhttp2modules. - HTTP/1.1 requests are parsed manually from bytes into method, path, query, headers, params, and body.
- HTTP/1.1 responses are generated manually with status line, headers,
Content-Length, and body. - Routes support method matching and
:params, such as/api/users/:id. - Static files are served from a mounted folder with directory traversal protection.
- Creative feature:
app.explorer("/__routes")exposes a live route explorer so developers can inspect the API they built.