koa-my-way
Adaptation of find-my-way that uses koa middlewares. Also, it can import routes defined by route-imperator.
Installation
npm install --save koa-my-way
Example
const koa = const router = router koa;
Modified API
router.on(method, path, [opts,] ...handlers[, store])
Defines a route, there are also shorthand methods available. Since koa already provides state management using ctx
, using store
is discouraged.
router;router;router; // Equivalent calls using shorthand methodsrouter
router.load(routes)
Load routes declared with route-imperator
or from another instance of koa-my-way
.
// routes/messages.js const routes = routes routes moduleexports = routes // routes/index.js const routes = const users = ;const messages = ; // Nest routes using a path prefixroutesroutes moduleexports = routes // router.js const router = const routes = router; moduleexports = router;
router.lookup(ctx, next)
Finds a route and executes handlers.
koa;
router.middleware()
Creates a koa middleware. It's a wrapper for lookup.
koa;
Remaining methods
The remaining methods are untouched, go to find-my-way for more information.