Based on KOA platform node. JS developed Koahub.js Controller, model, help method to automatically load

Source: Internet
Author: User

Koahub-loader

Koahub-loader is a koahub.js Koahub-loader controller based on the KOA Platform node. JS Development, model, help method automatically load

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

Based on KOA platform node. JS developed Koahub.js Controller, model, help method to automatically load

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.