Express is currently, and for many years, the de-facto library in the Node.js ecosystem. When you are looking for any tutorial to learn Node, Express is presented and taught to people.
Despite all of this, Express is not a great technology, and you should have stopped using it since 2015.
Express has not been updated for years, and its next version has been in alpha for 6 years.
People may think it is not updated because the API is stable and does not need change. The reality is: Express does not know how to handle
Matteo Collina@matteocollinaYet another Nodejs project recommends using async/await in Express middlewares.
I only see memory leaks everywhere. Hopefully from @nodejs v15 we crash on unhandledRejection.. at least they’ll all see their problems before reaching production. 🤞🏼20:53 PM - 13 Jan 2021
If you are using
async/await code inside your route's handler or middleware, you are prone to
UnhandledPromiseRejectionWarning exception. Express will not handle those exceptions for you because it does not know them.
You should know that from Node 15, your application will crash when encountering this exception, and before this version, you will have a memory leak.
async/await, you should always ensure that the library accepts an
AsyncFunction as a callback. Here is a great talk named Broken Promises about that.
The word "framework" is a wild term. When you are looking closer, Express is a routing library that supports middleware, but it is still called "a framework".
Evan You had a great talk about seeking the balance in a framework design. He said that we should categorize a framework by its scope.
We can categorize Express as a low-scope framework.
When you are building an application, you need more features than a routing system.
You need to:
- access a database;
- validate your data;
- create an authentication layer;
- create an authorization system;
All of those features are not inside Express and should be glued by yourself.
Romain Lanz 🦊I've always been amazed to see people fighting so hard to make something work by glueing modules instead of choosing a real solution to their problem. 😐
Stop creating your undocumented homemade-framework on top of routers and start working on what matter. twitter.com/_bitkidd/statu…07:37 AM - 10 Sep 2020Kirill @_bitkiddWrote a short story of my way to @adonisframework and why I chose it for every day work https://t.co/e6bCrXhqeK
Gluing those modules yourself means taking all the risk to add memory leaks, security holes, and bugs to your application. On top of that, you are only losing time and money because you should not be the one responsible for doing that.
What are the alternatives? What should we teach to people?
Even if I believe low-scope framework should not be used, there are few people that like this style or need one for learning purposes. In this category, you should look at fastify.
This framework is well maintained, and provides an official compatibility layer for Express to help you migrate your application.
If you prefer to have a high-scope fully-featured framework that lets you focus on your business logic, you can use AdonisJS.
There is no reason to stay with Express, only future pain that you can avoid today.
The goal of this section is to add a disclaimer to this article. I am not hating Express. I am sharing my perspective to help others make informed decisions and not follow the herd.
Express was one of the first frameworks in the Node.js ecosystem, and it was great for many years! But now, it is time to let it go.
I want to push the Node.js Ecosystem further and help newcomers to learn a technology that will not explode in their hands.