Appearance
Node mental model
The browser is event-driven UI. Node is an event-driven process that stays up and answers HTTP. Same JavaScript family, different job.
Process stays alive
In the browser, a page load creates a JS world, then teardown when you leave.
In Node + Express:
- You start a process (
node/tsx) - It listens on a port forever (until you kill it)
- Each HTTP request is an event - handlers run, then idle again
No "component tree". No hydration. Just: request in → functions → response out.
One thread, many requests (ish)
Node's main story is a single-threaded event loop. Blocking CPU work (huge JSON parse, sync crypto loops) stalls everyone. I/O (DB, network, disk) is async - so other requests can progress while you wait.
FE analogy: if you JSON.parse a 50MB blob on the main thread, the UI freezes. Same energy on the server - except "UI" is "every other API caller".
Practical takeaway: prefer async DB/drivers, don't fs.readFileSync in hot paths, keep handlers short.
Request / response objects
Every handler gets something like:
ts
app.get('/api/notes', (req, res) => {
// req = incoming (method, url, headers, body, params, query)
// res = outgoing (status, headers, body)
res.json({ notes: [] })
})You've seen cousins:
- Browser:
Request/Responseinfetch - Next route handlers:
(req) => Response.json(...) - Express:
req/reswith helper methods (res.status(404).json(...))
Middleware is the pipeline
Before your "real" handler, Express can run shared steps: parse JSON, log, check JWT, attach req.user.
That's the same mental slot as:
- Axios request interceptors
- Nuxt / Next middleware
- Vue Router
beforeEach
We'll dig into that in Middleware.
Modules = files, not "pages"
There is no pages/api/login.ts convention unless you invent one. You import routers and app.use them. Feels closer to a Vite app's src/ tree than to a file-based router.
Dev vs prod
While learning:
bash
tsx watch src/index.tsRestart on file change - like Vite HMR, but for the server process (clients may need a reconnect; it's not browser HMR).
In production people usually tsc → node dist/index.js, or bundle with esbuild. We'll stay on tsx for the tutorial so the feedback loop stays short.
As you can see, once you stop looking for React trees, Express is mostly "a long-lived process with a router".
Next: how I like to lay out folders before the code gets messy. 😅
Best,
-- ł.