How a Request Moves Through a Simple Node App

Developer with a passion for coding. I enjoy creating impactful applications and exploring new technologies. Let's embark on this coding adventure together, building innovative solutions along the way
Last year, I picked up Node.js. I was excited, building tiny apps, exploring Express, thinking I was finally getting the hang of backend stuff. Then… I didn’t touch it for months. Life happened.
When I resumed, I realized something funny: I could still write code that “worked”, but I couldn’t explain what actually happened when a request hit my server. Even something as simple as GET/users felt a little magical. That’s when I decided to slow down and trace a request from start to finish.
Following a request
To make sense of it, I decided to follow a request through a Node app step by step. Here’s what I mapped out:
The client sends a request - for example, a browser asking for
GET/usersNode receives it - the server picks up the request and starts looking for middleware or route handlers
Middleware runs - in my tiny test app, I just had a logger that prints “Request received”. Middleware can also transform or block requests
Route handler executes - Express finds a matching route and generates a response
Response goes back to the client - the browser finally gets the data or page it requested
Request lifecycle ends - everything resets, and Node waits for the next request
It’s very straightforward, but seeing it all together made everything click.
A tiny Node app for clarity
Here’s the minimal setup I used while retracing the flow:
const express = require('express')
const app = express()
// Middleware logs each request
app.use((req, res, next) => {
console.log('Request received');
});
// Route handler responds to /users
app.get('/users', (req, res) => {
res.send('User list');
});
// Start the server
app.listen(3000, () => {
console.log('Server is running on port 3000');
})
Noting fancy. One file, one route, one piece of middleware. But tracing a single request through this tiny app helped me understand the path every request takes.
Why this mattered
Coming back to Node after months of not touching it was humbling. I realized I wasn’t starting from scratch; I just needed to slow down and see the flow.
There’s still so much I’m figuring out, and I’ll be sharing each little discovery here on CodeWithKay
#NodeNuggets #CodeWithKay