import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg';
import defaultConfig from './config.default';

export default (appInfo: EggAppInfo) => {
  const config = {} as PowerPartial<EggAppConfig>;

  config.mongoose = {
    url: 'mongodb://dbop:zyzdbopbantu@dds-8vbdb47c6fb58a541.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vbdb47c6fb58a542.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-500808098', // 内网
    options: { useNewUrlParser: true, useUnifiedTopology: true },
  };
  config.redis = {
    url: 'r-8vb4i2kgl91886fkxd.redis.zhangbei.rds.aliyuncs.com', // 内网
    pw: 'zyz_2020'
  };

  config.xtransit = {
    server: 'ws://172.26.117.35:9092',
    appId: 3,
    appSecret: 'a48ad5ca44e2d02cbd7f4c0326fa3101',
    error_log: [ '/root/logs/zyz/zyz-web.log', '/root/logs/zyz/common-error.log', '/root/logs/zyz/egg-agent.log' ],
  };

  // the return config will combines to EggAppConfig
  return {
    ...defaultConfig(appInfo),
    ...config
  };
};
