View profile

Mastering JS - What Makes Express Awesome

Express became the dominant web server framework for Node.js around 2012-2013. To put it in perspecti
Mastering JS - What Makes Express Awesome
Express became the dominant web server framework for Node.js around 2012-2013. To put it in perspective, Angular 1 was released in 2012. Frontend frameworks have come and gone, but Express has remained unchallenged on the backend.
Here’s a couple ideas about what makes Express so successful:

Functions, not Classes
In languages like Python and Java, HTTP request handlers are typically defined as classes. HTTP request handler classes tend to suffer from dependency bloat: to instantiate a Python BaseHTTPRequestHandler class, you need to pass 3 parameters to the constructor, including a server instance. This makes it trickier to test a BaseHTTPRequestHandler in isolation and makes it harder to understand what the framework is doing.
In Express, a request handler is just a function. There’s nothing to instantiate. Express calls your function with 3 parameters: req, res, next. That means you can call your request handler function with fake parameters for testing.
Focus on Composability
In Express, everything is middleware. An Express app is fundamentally an array of middleware that gets executed sequentially on a request. Routers, plugins, etc. are all middleware. That means Express doesn’t have very many concepts or special cases: once you understand middleware, you understand Express.
This Week's Tutorials

Did you enjoy this issue?
Mastering JavaScript Tutorials

Mastering JavaScript Tutorials

If you don't want these updates anymore, please unsubscribe here
If you were forwarded this newsletter and you like it, you can subscribe here
Powered by Revue