Easy, rich, and fully validated koa routing. koa-joi-router returns a constructor that you use to define your routes. The design is such that you construct multiple router instances, one for each section of your application which you then add as koa middleware. The route definition for the currently matched route is available via ctx.state.route. This object is not the exact same route definition object that was passed into koa-joi-router, nor is it used internally - any changes made to this object will not have an effect on your running application but is available to meet your introspection needs. Validating the output body and/or headers your service generates on a per-status-code basis is supported. This comes in handy when contracts between your API and client are strict e.g. any change in response schema could break your downstream clients. In a very active codebase, this feature buys you stability. If the output is invalid, an HTTP status 500 will be used.
Features
- Built in input validation using joi
- Built in output validation using joi
- Built in body parsing using co-body and await-busboy
- Exxposed route definitions for later analysis
- String path support
- HTTP 405 and 501 support