koa-tracks
Koa middleware that runs multiple middleware at the same time - in parallel. Just like people are running tracks... in parallel.
Install
npm install --save koa-tracks
Usage
The koa-tracks
API is rather simple. The package returns a function that needs to be called with your middleware functions, to be executed in parallel.
API
tracks(...entries)
entries
List of middleware functions to be executed
Example
const Koa = ;const tracks = ; const app = ; app; // Start your serverapp;
All of them are going to be executed in parallel. That means you're saving time as all of them are doing a request at the same time.
Things you should be aware of
Errors
Under the hood koa-tracks
simply does a Promise.all
with the filtered entries. So, you need to properly handle a middleware when it errors. If not, the Promise.all
call will be rejected.
License
MIT