Skip to content

NodeFrameLightweight Core HTTP Framework for Node.js

Built purely from Node.js native core APIs with zero runtime dependencies. Clean routing, streaming JSON parser, middleware pipeline, and chainable response helpers.

Published on NPM • @harshitclub/nodeframe • Node >= 18

Install in Seconds

Add NodeFrame to your ESM Node.js project using your package manager of choice:

$npm install @harshitclub/nodeframeESM

Quick Example

Create an entire web server with JSON body parsing, route parameters, response helpers, and logging in less than 30 lines of code:

javascript
import NodeFrame, { parseJsonBody, logger } from "@harshitclub/nodeframe";

const app = new NodeFrame();

// 1. Register global middleware
app.use(logger());
app.use(parseJsonBody);

// 2. Define routes with query & route parameters
app.get("/users/:id", (req, res) => {
  const { id } = req.params;
  const { details } = req.query;

  res.status(200).json({
    success: true,
    user: { id, name: "Harshit", details: details === "true" }
  });
});

app.post("/users", (req, res) => {
  const { name, role } = req.body;

  res.status(201).cookie("session_user", name, { httpOnly: true }).json({
    success: true,
    message: "User created",
    data: { name, role }
  });
});

// 3. Start server
app.listen(3000, () => {
  console.log("Server listening on http://localhost:3000");
});

Why NodeFrame?

Most modern backend frameworks add thousands of lines of abstractions and dozens of external dependencies. NodeFrame was designed from the ground up using Node.js core modules to provide a lean, transparent, and modular foundation.

⚡ 100% Core Native

Built strictly on http.IncomingMessage and http.ServerResponse. Methods mutate the native object directly without runtime overhead.

⛓️ Chainable Response API

Fluid chaining like res.status(201).cookie(...).json(...) for clean and readable route handlers.

🛑 Resilient Error Boundary

Automatic try/catch wrapping around routes and middlewares. Thrown errors are safely routed to (err, req, res, next) handlers with a fallback 500 JSON response.


Request & Response Pipeline

Understanding how a request flows through NodeFrame:

Incoming HTTP Request


[ enhanceRequest() ]  ──> Attaches req.query (URLSearchParams)


[ enhanceResponse() ] ──> Attaches res.status(), res.json(), res.send(), res.cookie()


[ Middleware Stack ]  ──> Executes app.use() functions in order (e.g., logger, body parser)

       ├─── (If next(error) or thrown Error) ──► [ Error Pipeline ] ──► 500 JSON Fallback


[ Dynamic Router ]    ──> Matches path & extracts req.params (e.g. /users/:id)

       ├─── (If no route matches) ─────────────► HTTP 404 "Not Found"


[ Route Handler ]     ──> (req, res) handler sends response


Outgoing HTTP Response