Der erste Koahub-Loader KoaHub.js – Node.js Web-Rapid-Development-Framework basierend auf der Koa.js-Plattform Installation<br>
<br>
$ npm install koahub-loader<br>
Use with koa<br>
<br>
// 1.model loader<br>
var model = loader([<br>
{<br>
root: './app/model',<br>
suffix: '.model.js'<br>
},<br>
{<br>
root: './addon',<br>
suffix: '.model.js',<br>
filter: [/w*/model//]<br>
}<br>
]);<br>
<br>
// 2.controller loader<br>
var app = require('koa')();<br>
var router = require('koa-router')();<br>
var controller = loader([<br>
{<br>
root: './app/controller',<br>
suffix: '.controller.js',<br>
prefix: '/',<br>
}, {<br>
root: './addon',<br>
suffix: '.controller.js',<br>
prefix: '/addon/',<br>
filter: [/w*/controller//]<br>
}<br>
]);<br>
<br>
for (var key in controller) {<br>
router.use(key, controller[key].routes());<br>
}<br>
app.use(router.routes());<br>
<br>
// 3.util loader<br>
var util = loader([<br>
{<br>
root: './app/common',<br>
suffix: '.util.js'<br>
},<br>
{<br>
root: './addon',<br>
suffix: '.util.js',<br>
filter: [/w*/common//]<br>
}<br>
]);
Offizielle Website: http://js.koahub.com