
Day 25 of #100DaysOfCode — Middleware
Ever wondered what actually happens between your request leaving the client and the server sending something back? That hidden “in-between” magic is middleware. Middleware is one of those things in Express that sounds complicated at first… but once it clicks, everything in backend development suddenly makes more sense. Day 25 was all about understanding what middleware is and how we use it 🍽️ Middleware (Restaurant analogy) Think of a restaurant: You = the client (making a request) The kitchen = the server (sending a response) The waiter = middleware The waiter: Takes your order Passes it to the kitchen Brings food back AND can do extra checks (Are you allowed here? Is your order valid?) That’s exactly what middleware does. Middleware is simply a function that sits between the request and the response. It can: ▶ Authenticate users (“Is this user logged in?”) ▶ Log incoming requests ▶ Catch errors ▶ Modify or validate data ▶ Handle permissions ▶ Serve static files ▶ Parse request bodies
Continue reading on Dev.to Webdev
Opens in a new tab



