The name's a bit of a joke, I was just amused by the existence of koa-router and koa-better-router. This probably isn't the bestest Koa router.
When trying to track down an issue in another router, I was shocked by how much state mutation and code they were using. So I wrote this.
No mutations, not much code = easy to understand and debug. Intended for simple apps. If I need something more complex later, I'll come up with some way to compose or nest routers.
A single function. It takes a POJO map of HTTP methods to a map of routes to handler functions.
It returns a Koa middleware function.
const createRouter =const routerMiddleware =koaApp
routes is a map of HTTP methods to maps of path-to-regexp routes to handler functions.
Routes will be checked in a deterministic order from top to bottom, thanks to ES2015.
options is an object with only one supported property at the moment:
set404: defaults to false. When true, will set
context.status = 404when no matching routes are found for a request.