Node.js Without Express – Raw & Real (Day-13)

 

Backend from Scratch – Understanding Vanilla Node.js

Today I stepped into the world of backend development — but with a twist.
Instead of using the popular Express framework, I explored how to build a server and API endpoints using pure Node.js.

This helped me understand the core of how Node handles requests and responses, without any abstraction or shortcut — just pure JavaScript and built-in modules.


What I Covered:

 Theoretical Concepts:

  • What is Node.js and how it runs JavaScript outside the browser

  • Node’s non-blocking, event-driven architecture

  • Core modules like http, url, fs, and how they work internally

 Practical Learning:

  • Set up a basic HTTP server using the http module

  • Handled req.url and req.method to route traffic manually

  • Created simple API endpoints like:

    • / → Home

    • /about → About page

    • /api/users → Returns dummy JSON data

  • Parsed query params and request body without any libraries

  • Read and served static files using fs


 Key Learnings:

  • How raw Node.js handles each request without any framework

  • Manually routing and parsing data gives a clear view of what Express does for us under the hood

  • HTTP status codes and headers must be explicitly defined

  • APIs can be written from scratch using only JavaScript and native Node modules — that’s powerful!


 One  Challenge I Faced:

“Why isn’t the request body available directly like in Express?”

This was frustrating initially — I expected req.body to be available.
But in vanilla Node.js, the request body comes as a stream of data, not a ready object. So I had to manually collect chunks of data.

 Reading the Node.js documentation helped me understand this concept clearly — that unlike Express, Node doesn't auto-parse anything for us.


 Gracias:

I’m honestly glad I started with vanilla Node before jumping into Express.
Grateful for the resources, guidance, and this training structure that encourages building from the ground up.

~ Sanya

Comments

Popular posts from this blog

Revising GitHub CLI commands (Day1)

JavaScript Deep Dive + React Review (Day-5)

Starting the GitHub User Search App (Day - 2)