Socket
Socket
Sign inDemoInstall

advanced

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

advanced - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

cli/advanced.js

9

lib/controller.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc