lark
Version:
A node.js framework based on koa. Our goal is to build the best industrial node.js framework for high concurrency and high flow application.
31 lines (24 loc) • 704 B
JavaScript
/**
* Middleware to route requests
**/
;
const assert = require('assert');
module.exports = (app) => {
if (!app.config.has('routes')) {
return;
}
const config = app.config.get('routes');
assert(config instanceof Object, 'No routes found');
assert('string' === typeof config.directory, 'No routing handlers directory found');
if (config.routes) {
app.routes.use(config.routes);
}
else {
app.routes.use(config.directory);
}
if (app.config.has('mvc/proxy/controller')) {
config.proxy = app.config.get('mvc/proxy/controller');
}
app.routes.inject(app.router, config);
return app.router.routes();
};