const MYSQL = require('mysql')

const config = require('../config/dev.json')
const request = require('request')

request(config['remote_config_url'],{},(error, request, body)=>{
    const data = JSON.parse(body)
    const source = data['propertySources'][0]['source']
    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']
    const host = source['apollo.mysql.duiba_web_tool.url'].split(':')[0]
    const port = source['apollo.mysql.duiba_web_tool.url'].split(':')[1]
    const Mysql = MYSQL.createPool({
        'host': host,
        'port': port,
        'user': username,
        'password': password,
        'database': database,
        'connectionLimit': 1000
    })
    module.exports = Mysql
})





