DEV Community

Abdelrahman Ashraf
Abdelrahman Ashraf

Posted on

2

Create your own node framework

I've created a simple node framework just to get the idea behind node frameworks like express.

check the code in this repo.

GitHub logo theashraf / bare-node

A simple Node framework

Simple Node framework

what

  • A simple node framework with zero dependency
  • An Express like framework that implements the middleware pattern
  • For demonstration purpose only, not for production (maybe later)

why

To get the idea behind node frameworks specially express (the most popular node framework)

How

  • Middlewares handling is being implemented using the chain of responsibility pattern, check lib/App.js to see the implementaion details
  • Extending the http.ServerResponse object functionality by adding some util method that make it easier to send response, it uses the builder pattern to build the response before sending it to the client, check lib/Response.js
  • Adding BodyParser middleware that parse the request body by listening to the http.IncommingMessage on data event and keep concatinating the incomming buffer chunks until the end event fires, then it will call the next middleware after adding the body object to the req , so later we can access the body in our…

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

The only thing worse than downtime? No Answers.

If you’re sometimes frustrated with opaque infrastructure, sluggish support, and mysterious outages, we prepared a webinar just for you

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️