致tp开发者,node之路koahubjs第一弹
程序员文章站
2022-04-12 16:37:13
...
第一弹 koahub-loader KoaHub.js -- 基于 Koa.js 平台的 Node.js web 快速开发框架
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\//]
}
]);
官网:http://js.koahub.com 上一篇: 使用PHP实现微信摇一摇周边红包,周边红包_PHP教程
下一篇: 一年没来,循例散分,该怎么处理