compose
compose copied to clipboard
Middleware composition utility
Bumps [jest](https://github.com/facebook/jest/tree/HEAD/packages/jest) from 27.5.1 to 28.1.3. Release notes Sourced from jest's releases. v28.1.3 Features [jest-leak-detector] Use native FinalizationRegistry when it exists to get rid of external C dependency (#12973) Fixes...
The current jsdocs aren't descriptive enough for typescript to understand that this middleware is compatible with Koa. I've updated them to specify that compose takes and returns a Koa.Middleware.
This is an implementation of what was outlined in #63. Super simple but it does require dropping support for node
To address the issue outlined in #74 and the original ticket in the koa repo, I've refactored the recursion implementation to make it easier to keep track of whether or...
function compose (middleware) { if(!Array.isArray(middleware)) throw TypeError('Middleware stack must be an array!') for (const fn of middleware) { if(typeof fn !== 'function') throw new TypeError('Middleware must be composed of functions!')...
Bumps [standard](https://github.com/standard/standard) from 16.0.4 to 17.0.0. Release notes Sourced from standard's releases. v17.0.0 We're super excited to announce standard 17! This major release fully focuses on getting in sync with...
It would be nice to be able to choose the Promise constructor to compose the middleware. This does not affect performance in any way but makes the helper more flexible....
I want to add an 'end()' function to provide an option, it's able to backtrack previous middleware for early return.
some API for extending externally, for example the new debug stuff I just added could live in a different module. I'd like to provide a nicer alternative that outputs HTML...
this is just my ocd, but imo the latter looks much nicer: ``` js app.use(route.get('/foo', compose([ middleware1, middleware2, routeHandler ]))) ``` vs ``` js app.use(route.get('/foo', compose(middleware1, middleware2, routeHandler))) ``` would...