Helpful Koa Routing
Note: Many of the examples in this documentation use ES2015 destructuring. ES2015 is not required to use this library!
Install the package via
npm install --save helpful-koa-routing
Then require it like so...
const route = ;
This library exposes functions that make your existing middleware only response to certain HTTP method + path combinations. The basic methods are supported along with a
route function for creating routes that support multiple methods.
const route GET = ;app;app;
Path parameters, similar to Express, can also be used. These will be made available on your context as a
Typically, it's encouraged to use koa-compose to combine multiple middleware into one before passing it to higher-order functions in order to maintain functional composition and separation of concerns. However, we've decided to implement middleware composition for you to save the additional step and
To use multiple middleware, simply provide an array of middleware instead of a single middleware function.