Throwback
Simple asynchronous middleware pattern.
Installation
npm install throwback --save
Usage
Compose asynchronous (promise-returning) functions.
const compose = ; const fn = ; // Callback runs at the end of the stack, before// the middleware bubbles back to the beginning.;
Tip: In development (NODE_ENV !== "production"
), compose
will throw errors when you do something unexpected. In production, the faster non-error code paths are used.
Example
Build a micro HTTP server!
const createServer = ;const finalhandler = ; // Example only, not compatible with single `ctx` arg.const compose = ; const app = ; ;
Use Cases
Inspiration
Built for servie
and inspired by koa-compose
.
License
MIT