Home > php教程 > php手册 > KoaHub controller, model, automatic loading developed based on Koa platform Node.js

KoaHub controller, model, automatic loading developed based on Koa platform Node.js

WBOY
Release: 2016-09-27 14:04:32
Original
1274 people have browsed it

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
KoaHub controller, model, automatic loading developed based on Koa platform Node.js

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template