index.js 2.47 KB
'use strict';

var fs = require('fs');
var path = require('path');
var session = require('express-session');
var Redis = require('connect-redis')(session);

var config = JSON.parse(fs.readFileSync('./package.json').toString());

var grayroute = require("./mid/grayrouter");

/*session 配置*/
var options = {
    secret: 'yohobuy.portal', //session配置
    cookie: {secure: false, maxAge: 3600000},
    resave: false,
    saveUninitialized: true
};

/*老平台接口 配置*/
var oldSerDomain = 'http://serve.yohobuy.com';
var Iaccount = {
    WEBSITE: 2,
    login: oldSerDomain + '/service/account/v1/Profile/login',
    getResourceByPid: oldSerDomain + '/service/account/v1/Profile/getMenuByPid',
    getAllResByWebsite: oldSerDomain + '/service/setting/v1/menu/getAllMenu',
    changeShops: 'http://shops.yohobuy.com/index/ajaxshop',
    isUsedMenuAuth: oldSerDomain + '/service/account/v1/profile/authPath',
    allRight: oldSerDomain + '/service/setting/v1/action/getAllAction',

    getShopList: '{domain}/ShopsRest/queryShopsByAdminPid',
    
    // 灰度代理
    url: 'http://shops.yohobuy.com',
    sessionKeep: '/account/profile/display',
    timeout: 30000
};



/*框架配置*/
var apiCofig = {
	//root:__dirname,
	EnvConst:{
		domain:"http://192.168.102.202:8088/platform",
		bigdata:"http://192.168.102.210:8091/bigdata",
		system:Iaccount
	},
	apps:path.join(__dirname,"apps"),
    port: 3000,
	log:{
		consoles:['log', 'info', 'warn', 'error'],
		src:path.join(__dirname,"..","logs")
	},
	mock:false,
	baseUrl:'/',
	static: {name:"static",value: '../dist/'+ config.version+"/static"},
    MVC: {
        //开发环境
		Interfacer:path.join(__dirname,"apps/0/interfaces/1.js").replace(/0|1/g,'*'),
		Controller:path.join(__dirname,"apps/0/controllers/1.js").replace(/0|1/g,'*'),
        filters: path.join(__dirname, "filters.js"),
        views: path.resolve(__dirname,"apps", "0", "views/1")
	},
	useToEntry:function(app){
		app.use(session(options));
	},
	useToOuter:function(app,controllers){
		app.use(grayroute(controllers));
	}
};
if(process.env.NODE_ENV){
	apiCofig.log.src="/Data/logsnode/yohobuy-portal-log/"
}
/*环境配置*/
if(process.env.NODE_ENV==="test"){
	apiCofig.MVC={
		Interfacer:path.join(__dirname,"interfaces/0.js").replace(/0/g,'*'),
		Controller:path.join(__dirname,"controllers/0.js").replace(/0/g,'*'),
        filters: path.join(__dirname, "filters.js"),
        views: path.resolve(__dirname,"views", "0", "views/1")
	}
}
module.exports = require('./libs/App')(apiCofig);