Not a Middy Fan

I feel like those using Middy, and enjoying it, missed the whole “Promises were invented” thing. Nowadays you can just chain functions together. There is no need for all of this side-effects everywhere, global variables like process.env being passed around, and bizarre “thing piece | void” return values. Just have your handler being a Promise / Result chain.

Express.js was created around the time callbacks were _the_ architecture in Node.js. The world, including UI, quickly found callbacks do not compose well, and void return values are hard to test because of side-effects. Promises were created so you could compose functions, but still have control where your side-effects go. This negates the need for middlewares / callbacks.

However, Express.js hold on the Node.js server market was so strong and beloved, Middy made it work for AWS Lamda. The productivity gains and adoption is clearly there. I’ll acknowledge that. Given the choice, though, I’d never intentionally use this framework again given the choice. I’d just use Promises instead.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *