Loads in any koa middlewares and attaches them to the global scope, or an object of your choice.
$ npm install --save koa-load-middlewares
package.json file that has some dependencies within:
Adding this into your koa server file:
var koa = ;var koaLoadMiddlewares = ;var middlewares = ;
Or, even shorter:
var middlewares = ;
Will result in the following happening (roughly, plugins are lazy loaded but in practice you won't notice any difference):
middlewaresswig = ;middlewaresbodyparser = ;
You can then use the plugins just like you would if you'd manually required them, but referring to them as
middlewares.name(), rather than just
This frees you up from having to manually require each koa middleware.
You can pass in an object of options that are shown below: (the values for the keys are the defaults):