index.js
3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
'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.shops', //session配置
cookie: {secure: false, maxAge: 7200000},
resave: false,
saveUninitialized: true,
rolling: 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.210:8088/platform",
bigdata:"http://192.168.102.210:8091/bigdata",
// bigdata:"http://172.16.6.169:8080",//钟文
// bigdata:"http://172.16.6.189:8080/bigdata",//李建
system:Iaccount
},
apps:path.join(__dirname,"apps"),
port: 30016,
log:{
consoles:['log', 'info', 'warn', 'error'],
src:path.join(__dirname,"..","logs")
},
mock:false,
baseUrl:'/',
static: {name:"static",value: '../dist/'+config.name+'/'+ config.version},
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){
if(process.env.NODE_ENV!="coding"&&process.env.NODE_ENV!=="test"){
options.store=new Redis({
port: 6379,
host: 'localhost'
});
}
app.use(session(options));
},
useToOuter:function(app,controllers){
app.use(grayroute(controllers));
}
};
console.log("环境:"+process.env.NODE_ENV);
if(process.env.NODE_ENV!=='development'){
apiCofig.log.src="/Data/logs/node/yohobuy-shops-log/"
}
/*环境配置*/
if(process.env.NODE_ENV!="coding"){
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", "1")
}
}
/*线下测试环境*/
if(process.env.NODE_ENV==="test211"){
apiCofig.EnvConst.domain="http://192.168.102.202:8088/platform";
apiCofig.EnvConst.bigdata="http://192.168.102.202:8091/bigdata";
}
/*腾讯云*/
if(process.env.NODE_ENV==="test"){
apiCofig.EnvConst.domain="http://10.66.100.6:8088/platform";
apiCofig.EnvConst.bigdata="http://10.66.100.7:8091/bigdata";
}
// 灰度
if(process.env.NODE_ENV==="gray"){
apiCofig.EnvConst.domain="http://172.31.23.161:8088/platform";
apiCofig.EnvConst.bigdata="http://172.31.23.161:8091/bigdata";
}
//线上
if(process.env.NODE_ENV==="production"){
apiCofig.EnvConst.domain="http://172.31.20.7:8088/platform";
apiCofig.EnvConst.bigdata="http://172.31.20.7:8091/bigdata";
}
module.exports = require('./libs/App')(apiCofig);