DEV Community

Discussion on: Simple, but not too simple: how using Zeit’s `micro` improves your Node applications

Collapse
 
lesbaa profile image
Les • Edited

I love micro, it just makes building small apps a sinch. But then I'm a total Zeit fanboy.

If you're really want to functionify it. Where you apply your middlewares with micro you could compose with lambda or some other functional library.

const compose = require('some-functional-library/compose')

const applyMiddlwares = compose(
  health,
  log,
  cors,
  rateLimit,
)

module.exports = applyMiddlewares(handler)
Collapse
 
hugo__df profile image
Hugo Di Francesco

Yep, I mean compose is just a reduce away isn't it?

😉