...
|
...
|
@@ -2,6 +2,10 @@ var path = require('path'); |
|
|
|
|
|
var express = require('express');
|
|
|
var App = express();
|
|
|
var bodyParser = require('body-parser');
|
|
|
var multer = require('multer');
|
|
|
|
|
|
|
|
|
var Router = express.Router();
|
|
|
|
|
|
var Scan=require("./Scan");
|
...
|
...
|
@@ -20,6 +24,7 @@ module.exports=function(apiCofig){ |
|
|
/*接口层*/
|
|
|
var Interfacer=require("./Interfacer");
|
|
|
var InterRegisters= new Interfacer(apiCofig);
|
|
|
apiCofig.MVC.Interfacer&&
|
|
|
Scan(apiCofig.MVC.Interfacer).forEach(function(src){
|
|
|
InterRegisters.register(require(src));
|
|
|
});
|
...
|
...
|
@@ -27,18 +32,25 @@ module.exports=function(apiCofig){ |
|
|
/*过滤器*/
|
|
|
var Filter=require("./Filter");
|
|
|
var FilterRegisters= new Filter(InterRegisters);
|
|
|
apiCofig.MVC.filters&&
|
|
|
Scan(apiCofig.MVC.filters).forEach(function(src){
|
|
|
require(src)(FilterRegisters);
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/*控制器层*/
|
|
|
var Controller=require("./Controller");
|
|
|
var ContRegisters=new Controller(InterRegisters);
|
|
|
apiCofig.MVC.Controller&&
|
|
|
Scan(apiCofig.MVC.Controller).forEach(function(src){
|
|
|
require(src)(ContRegisters);
|
|
|
});
|
|
|
|
|
|
/*内置中间件 对Http请求解析*/
|
|
|
App.use(bodyParser.json()); // for parsing application/json
|
|
|
App.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
|
|
|
// App.use(multer()); // for parsing multipart/form-data
|
|
|
|
|
|
/*路由控制*/
|
|
|
var KLH=function(obj,method,guid){
|
...
|
...
|
@@ -53,7 +65,7 @@ module.exports=function(apiCofig){ |
|
|
ROU[router.method].apply(ROU,args);
|
|
|
});
|
|
|
|
|
|
App.use(apiCofig.uri, Router);
|
|
|
App.use(apiCofig.baseUrl, Router);
|
|
|
|
|
|
|
|
|
/*View 设置*/
|
...
|
...
|
|