koahub-loader is the koahub-loader controller, model, and helper method of KoaHub.js developed based on Koa platform Node.js. Automatic loading
koahub-loader
koahub-loader is the koahub-loader controller, model, and helper method of KoaHub.js developed based on Koa platform Node.js for automatic loading
koahub loader
Installation
$ npm install koahub-loader
Use with koa
// 1.model loader
var model = loader([
{
root: './app/model',
suffix: '.model.js'
},
{
root: './addon',
suffix: '.model.js',
filter: [/w*/model//]
}
]);
// 2.controller loader
var app = require('koa')();
var router = require('koa-router')();
var controller = loader([
{
root: './app/controller',
suffix: '.controller.js',
prefix: '/',
}, {
root: './addon',
suffix: '.controller.js',
prefix: '/addon/',
filter: [/w*/controller//]
}
]);
for (var key in controller) {
router.use(key, controller[key].routes());
}
app.use(router.routes());
// 3.util loader
var util = loader([
{
root: './app/common',
suffix: '.util.js'
},
{
root: './addon',
suffix: '.util.js',
filter: [/w*/common//]
}
]);
Official website: http://js.koahub.com