moajs / moa-api

一个基于node express快速开发api类后端的框架,适用于angularjs和ionic等前后端分离的项目
https://github.com/moajs/moa-api
MIT License
250 stars 55 forks source link

关于require('mount-controllers')加载类的问题 #5

Closed jameBoy closed 9 years ago

jameBoy commented 9 years ago

var $middlewares = require('mount-middlewares')(__dirname);

// core controller var $ = require('mount-controllers')(__dirname).users_controller;

这里的require('mount-controllers')(dirname)和 require('mount-middlewares')(dirname);是什么样的用法?

i5ting commented 9 years ago

hi

require('mount-controllers')(__dirname)会加载当前目录下的app/controllers下的所有文件,

比如users_controller.js

那么它就是

var $ = require('mount-controllers')(__dirname).users_controller;

这样可以少些一些代码,另外对生成器会非常友好