Commit f53fa372 authored by wty's avatar wty

重写阿波罗配置获取

parent bcb426bc
......@@ -15,6 +15,7 @@
<content url="file://$MODULE_DIR$/node_modules" />
<content url="file://$MODULE_DIR$/node_modules/@types" />
<content url="file://$MODULE_DIR$/server/node_modules" />
<content url="file://$MODULE_DIR$/server/node_modules/@tuia/apollo" />
<content url="file://$MODULE_DIR$/server/node_modules/@types" />
<content url="file://$MODULE_DIR$/server/node_modules/sso-oauth2" />
<orderEntry type="inheritedJdk" />
......
{
"PORT": "3000",
"API_HOST": "//dui123.duibadev.com.cn",
"env": "dev",
"SSO": {
"ssourl": "http://sso.duibadev.com.cn",
"systemId": 491,
......@@ -8,5 +9,5 @@
"systemName": "duiba-aurora-node",
"profiles": "dev"
},
"remote_config_url": "http://configserver.duiba.com/dui123/dev?accessKey=5d0cb61fe5ef40afa49bc22b64f9ede1"
"secret": "http://configserver.dui88.com/dui123/dev?accessKey=5d0cb61fe5ef40afa49bc22b64f9ede1"
}
const env = 'test'
const env = 'dev'
const getConfig = ()=>{
switch (env){
......
{
"PORT": "3000",
"API_HOST": "//dui123.duiba.com.cn",
"env": "prod",
"SSO": {
"ssourl": "http://sso.duiba.com.cn",
"systemId": 491,
......
{
"PORT": "3000",
"API_HOST": "//dui123.duibatest.com.cn",
"env": "test",
"SSO": {
"ssourl": "http://sso.duibatest.com.cn",
"systemId": 491,
......
const MYSQL = require('mysql')
const request = require('request')
const config = require('../config/getConfig')()
const apollo = require('@tuia/apollo')
//应用数据库
console.info('CONFIG:',config)
const getMysql = new Promise((resolve)=>{
request(config['remote_config_url'],{},(error, request, body)=>{
if (error)console.error('MySql.js :',error)
console.info('apolloConfig:',body)
const data = JSON.parse(body)
const source = data['propertySources'][0]['source']
console.info('CONFIG:', config)
const getApollo = async () => {
const config = await apollo.getApolloConfig({
systemName: 'dui123',
env: config.env,
accessKey: config.secret
})
console.info(config)
const sourcesArray = config.propertySources.map(v => v.source);
const sources = Object.assign({},...sourcesArray)
return sources
}
const getMysql = new Promise(async (resolve) => {
const source = await getApollo()
const username = source['apollo.mysql.duiba_web_tool.username']
const password = source['apollo.mysql.duiba_web_tool.password']
const database = source['apollo.mysql.duiba_web_tool.database']
......@@ -24,9 +33,8 @@ const getMysql = new Promise((resolve)=>{
'connectionLimit': 1000
})
// console.info('MysqlConfig:',Mysql.config)
console.info('OBJMysql',Mysql)
console.info('OBJMysql', Mysql)
resolve(Mysql)
})
})
// 本地数据库
......
......@@ -7,6 +7,7 @@
"start": "node app.js"
},
"dependencies": {
"@tuia/apollo": "^0.1.0",
"@types/express": "^4.17.13",
"@types/mysql": "^2.15.19",
"axios": "^0.18.0",
......
......@@ -107,6 +107,14 @@
resolved "http://npm.dui88.com:80/@tootallnate%2fonce/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82"
integrity sha1-zLkURTYBeaBOf+av94wA/8Hur4I=
"@tuia/apollo@^0.1.0":
version "0.1.0"
resolved "http://npm.dui88.com:80/@tuia%2fapollo/-/apollo-0.1.0.tgz#b1ea17e7f498c0b1325437471285e7156786d5fa"
integrity sha512-WVsGr2VQLGDxmO86tgGndKHDBodLFLFv1hXX+E95m2fFu/NNbqAqE+0XZL/QKn+d+TKb6Fmv9YsCJ/O1/HaYDg==
dependencies:
axios "^0.20.0"
lodash "^4.17.20"
"@types/body-parser@*":
version "1.19.1"
resolved "http://npm.dui88.com:80/@types%2fbody-parser/-/body-parser-1.19.1.tgz#0c0174c42a7d017b818303d4b5d969cb0b75929c"
......@@ -600,6 +608,13 @@ axios@^0.19.0:
dependencies:
follow-redirects "1.5.10"
axios@^0.20.0:
version "0.20.0"
resolved "http://npm.dui88.com:80/axios/-/axios-0.20.0.tgz#057ba30f04884694993a8cd07fa394cff11c50bd"
integrity sha1-BXujDwSIRpSZOozQf6OUz/EcUL0=
dependencies:
follow-redirects "^1.10.0"
axios@^0.21.0:
version "0.21.4"
resolved "http://npm.dui88.com:80/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575"
......@@ -2189,7 +2204,7 @@ follow-redirects@1.5.10:
dependencies:
debug "=3.1.0"
follow-redirects@^1.14.0:
follow-redirects@^1.10.0, follow-redirects@^1.14.0:
version "1.14.4"
resolved "http://npm.dui88.com:80/follow-redirects/-/follow-redirects-1.14.4.tgz#838fdf48a8bbdd79e52ee51fb1c94e3ed98b9379"
integrity sha1-g4/fSKi73XnlLuUfsclOPtmLk3k=
......@@ -3085,7 +3100,7 @@ locate-path@^5.0.0:
dependencies:
p-locate "^4.1.0"
lodash@^4.13.1, lodash@^4.17.14, lodash@^4.17.4:
lodash@^4.13.1, lodash@^4.17.14, lodash@^4.17.20, lodash@^4.17.4:
version "4.17.21"
resolved "http://npm.dui88.com:80/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha1-Z5WRxWTDv/quhFTPCz3zcMPWkRw=
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment