Fascia: Improving on Express by Brian Schiller
Details
Talk:
Fascia: Improving on Express
Express has served the Node.js community pretty well, but it's starting to show its age. Frameworks from other languages have explored new ground, and we can learn from their work. We can leverage TypeScript to improve our ability to reason about code, and catch errors early. In this talk, I will propose a new framework that improves upon express, specifically in these ways:
- Built on express' foundation. No reason to throw away the many existing libraries and codebases already using express.
- "Type-aware middleware". If middleware adds a req.user or req.token property, we should have type-level confirmation. If the middleware isn't included, we should get a compile-time error in trying to use it.
- Consistent returns. Express controllers and middleware have five different ways to terminate. Let's reduce that to 2: success and error.
- Promises instead of callbacks. Return values instead of mutations. In addition to the usual benefits, this change makes controllers and middleware easier to test and more composable. We'll see that promises are the key to our accomplishing our other improvements
