mu-kōän-router 公案-ルータ
Automatic routes discovery and declaration for mu-kōän applications.
npm i --save mu-koan-router
Usage
Write your controllers (see below) and place them under a single root directory. Tell mu-koan-router
where you store them and let the module do the setup for you.
'use strict';/** * Configures a Koa app and exports it. */const Koa = ;const router = ; // Create Koa app instancelet app = ; // Setup routes using controllers found// on ./routes directory and configure them// under a "/v1" namespace.router; // Export the configured applicationmoduleexports = app;
Controllers
A controller is node module that exports a function
that receives a koa-router
instance and declares something on it. All controllers must be defined under a single root directory (but can be nested as needed).
For example,
'use strict';/** * Implementation of API /hello endpoint. * @module routes/hello */const moment = ; /** * Set up /hello endpoint. * @param */module { /** * GET /hello * * Returns a simple hello world * text and a timestamp. */ router;};
License
MIT