"Web Dev Saga: Week 10 :– Mastering Express.js Fundamentals: Routing, Middleware & EJS Templating"


Things I Learned This Week :-
This week, I explored Express.js, one of the most popular Node.js frameworks for building web applications. Here’s a breakdown of what I covered:
Introduction to Express.js – Learned the fundamentals of Express.js, including how it simplifies backend development with its minimalistic and flexible approach. Set up an Express server and understood its core functionality. Want to dive deeper? Check out my keynotes.
Response, Request, and Routers in Express – Explored how Express handles incoming HTTP requests using request and response objects. Implemented routing to define different endpoints and practiced sending various responses such as JSON, HTML, and status codes. Curious to know more? Head over to my keynotes.
Middlewares in Express.js – Understood the role of middleware functions in processing requests before sending a response. Practiced using built-in, third-party, and custom middleware for tasks like logging, authentication, and error handling. Want to see the practical implementations? Check out my keynotes.
EJS Template Engine in Express – Learned how to integrate EJS (Embedded JavaScript) with Express to dynamically generate HTML pages. Practiced passing data from the backend to templates and using loops, conditionals, and partials to structure templates efficiently. For more details, check out my keynotes.
Steps That I Did :-
This week, I focused on strengthening my backend skills with Express.js. Here’s how I structured my learning:
Setting Up Express.js – Started by installing Express using npm and setting up a basic Express server. Explored how to create routes and send responses to client requests.
Working with Requests, Responses & Routers – Practiced handling different HTTP methods (GET, POST, PUT, DELETE) using Express routes. Implemented query parameters, route parameters, and request body parsing using express.json() and express.urlencoded().
Implementing Middlewares in Express.js – Explored built-in, third-party, and custom middlewares to process requests. Used Morgan for logging, Cors for handling cross-origin requests, and created custom middleware for authentication and error handling.
Using EJS as a Template Engine – Integrated EJS (Embedded JavaScript Templates) with Express to dynamically render HTML pages. Passed data from the backend to templates, used loops and conditionals, and created reusable components with partials.
Challenges I Faced and How I Overcame Them :-
Understanding Request, Response, and Routing
Challenge: Initially, I found it confusing to handle different HTTP methods and correctly pass parameters in Express routes.
How I Overcame It: I broke down each method (GET, POST, PUT, DELETE) and practiced them with sample APIs. Reading the Express documentation and experimenting with different route structures helped solidify my understanding.Middleware Execution Flow
Challenge: At first, it was tricky to understand the execution order of middlewares and how they interact with request-response cycles.
How I Overcame It: I logged messages inside different middleware functions to track their execution order. I also explored built-in, third-party, and custom middlewares separately to understand their roles.
Resources I Used :-
Documentation :- Express JS
Conclusion :-
This week has been an incredible journey into the world of Express.js, where I explored the fundamentals of handling requests and responses, routing mechanisms, middleware, and dynamic templating with EJS. Each concept I practiced helped me build a stronger foundation for backend development, giving me a clearer picture of how web applications handle data and render dynamic content.
While some concepts initially seemed complex—especially middleware execution and dynamic templating—breaking them down through hands-on coding made all the difference. The deeper I dive into backend development, the more I realize how powerful Node.js and Express.js are in creating efficient and scalable applications.
Excited for the next chapter in this learning journey! Onward to more backend adventures! 🚀🔥
Subscribe to my newsletter
Read articles from Dhairya Khanna directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
