DEV Community

Cover image for Simple, but not too simple: how using Zeit’s `micro` improves your Node applications

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

Hugo Di Francesco on October 22, 2018

Leave the Express comfort zone to expand how you think about Node application architecture. tl;dr using a function composition model for build...
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?

😉