I have an API that I would like to create using Express. It will contain a couple of layers: authentication, cache, database access.I want to make the most out of middleware and decouple my code with something along the lines of:app.get('/product/:id', authMiddleware, cacheMiddleware, productController.getProduct); Where the cacheMiddleware will return the data from cache or call the next middleware if there is a cache miss. I feel this will make unit testing each component a lot easier. Is this a common pattern? And what are some cons of this pattern?
Submitted November 22, 2015 at 11:15PM by SquattingWalrus
No comments:
Post a Comment