Comparing version 0.0.2 to 0.1.0
@@ -7,4 +7,2 @@ var _ = require('lodash'), | ||
request = request.defaults({baseUrl: Utils.c('api')}); | ||
var Controller = function() { | ||
@@ -21,6 +19,6 @@ this._init.apply(this, arguments); | ||
this.next = next; | ||
this.api = Utils.c('api'); | ||
}, | ||
index: _.noop, | ||
/** | ||
@@ -48,3 +46,4 @@ * 渲染模板 | ||
method: self.req.method, | ||
json: true | ||
json: true, | ||
baseUrl: self.api | ||
}, function(error, response, body) { | ||
@@ -51,0 +50,0 @@ if (error) { |
@@ -1,15 +0,16 @@ | ||
var Express = require('express'); | ||
var Express = require('express'), | ||
bodyParser = require('body-parser'), | ||
Path = require('path'), | ||
_ = require('lodash'), | ||
Promise = require('bluebird'), | ||
Utils = require('./utils'); | ||
/** | ||
* 创建Express app | ||
* @returns {*|exports} | ||
*/ | ||
function createApp() { | ||
var app = Express(); | ||
// 加载自定义配置 | ||
try { | ||
var config = require(Path.join(Utils.c('root'), '/config/config.js')); | ||
Utils.c(config); | ||
} catch (e) {} | ||
loadCustomConfig(); | ||
@@ -19,3 +20,27 @@ app.use(bodyParser.json()); | ||
// 加载路由 | ||
var router = loadRoutes(); | ||
router.simpleRoute(); | ||
app.use('/', router); | ||
return app; | ||
} | ||
/** | ||
* 加载自定义配置 | ||
* @returns {*|Array|Object} | ||
*/ | ||
function loadCustomConfig() { | ||
var configPath = Utils.c('root') + '/config'; | ||
Utils.fs.readdirSync(configPath) | ||
.map(function(file) { | ||
var config = require(Path.join(configPath, file)); | ||
Utils.c(config); | ||
}); | ||
} | ||
/** | ||
* 加载路由配置 | ||
* @returns {*} | ||
*/ | ||
function loadRoutes() { | ||
var router; | ||
@@ -30,6 +55,4 @@ try { | ||
} | ||
router.simpleRoute(); | ||
app.use('/', router); | ||
return app; | ||
return router; | ||
} | ||
@@ -36,0 +59,0 @@ |
@@ -8,5 +8,2 @@ var Express = require('express'), | ||
var controllerPath = Utils.c('controllerPath'), | ||
defaultAction = Utils.c('defaultAction'); | ||
var Route = Utils.inherit(Express.Route, {}); | ||
@@ -18,2 +15,5 @@ | ||
var controllerPath = Utils.c('controllerPath'), | ||
defaultAction = Utils.c('defaultAction'); | ||
callbacks.forEach(function(fn) { | ||
@@ -20,0 +20,0 @@ if (typeof fn === 'string') { |
var _ = require('lodash'), | ||
Promise = require('bluebird'), | ||
fs = Promise.promisifyAll(require('fs-extra')), | ||
config = require('../config/advance'); | ||
config = require('../config/advanced'); | ||
@@ -6,0 +6,0 @@ var Utils = module.exports = { |
{ | ||
"name": "advanced", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "A simple MVC framework based on Express", | ||
"main": "./lib/index.js", | ||
"bin": "./cli/advanced.js", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Javey/advanced" | ||
}, | ||
"dependencies": { | ||
@@ -7,0 +13,0 @@ "bluebird": "^2.9.25", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
14062
19
0
370
1
78
6