Backend
You Don't Need Express to Build a Microservice (Here's the Zero-Dependency Version)
Dev Encyclopedia DEV Community
1 views
Open ten "Node.js microservices" tutorials and nine start the exact same way: install Express, install an HTTP client, write a docker-compose.yml, stand up a message broker. By the time application code shows up, you've installed six things and still don't know if microservices were even the right call.
Node ships with everything two communicating services actually need. node:http is the server. Global fetch is the client. node:test is the runner. --watch is the reloader. No install step, no node_modules.
So I built two real services this way: a user service holding user records, and an order service that has to confirm a user exists before creating an order for them, calling across the boundary with a plain fetch. Along the way you run into the actual failure modes of distributed systems, not the theoretical ones. fetch rejects on a refused connection instead of returning a response object, which means an unhandled rejection inside your request handler can take your service down right along with the one it was calling. That single try/catch is the whole lesson.
The bigger trap isn't technical though. It's splitting a codebase into two folders while both still connect to the same schema. That gets you all the operational cost of distributed systems and none of the actual benefit, independent deployability included.
I walk through building both services, testing them with node:test, and watching the failure happen live (kill one service, watch the other survive, then watch it not survive once you remove the catch) here: https://devencyclopedia.com/blog/nodejs-microservices-without-express
If you've been reaching for Express and Docker by default before writing a line of logic, this is worth forty lines of your time first.
Read original: https://dev.to/dev_encyclopedia/you-dont-need-express-to-build-a-microservice-heres-the-zero-dependency-version-921
← Previous
Daily Dose of DevOps — Terraform remote state explained
Next →
Your AI agent can plan anything. It still can't click "Post".
Related
Should Your Thread Keep the JVM Alive?
Backend
7
Dev.to (EN Zone)
Monitoring Jetson CPU, GPU, Temperature and Power from a Flutter Robot Dashboard
Backend
7
DEV Community
Stop Slamming Downstream Services: Singleflight Request Coalescing with Java Virtual Threads
Backend
6
DEV Community
Nothing could start without the dependency we had filed as optional
Backend
8
DEV Community
Comments0
No comments yet — be the first