First, we need to sketch out what the API will look like:
- First, we create an instance of our Middleware library:
const instance = new Middleware()
- Next, we load some middleware functions, which call the next() function after they are done:
instance.use(next => ...)
- Finally, we start our instance and let it run through all middleware functions. We can pass a function to the run method, which will be called after all middleware functions are done:
instance.run(() => ...)