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:zyzSQ72022@dds-8vbf3dbcaaeec4441.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vbf3dbcaaeec4442.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-512156065', // 内网
    options: { useNewUrlParser: true, useUnifiedTopology: true },
  };
  config.gmmongoose = {
    url: 'mongodb://dbop:zyzSQGm2021@dds-8vb5de93552a67941.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb5de93552a67942.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb5de93552a67943.mongodb.zhangbei.rds.aliyuncs.com:3717/zyzgm?readPreference=secondary&replicaSet=mgset-508112742', // 内网
    options: { useNewUrlParser: true, useUnifiedTopology: true },
  };
  config.redis = {
    url: 'r-8vb53gmaww4042b2qb.redis.zhangbei.rds.aliyuncs.com', // 内网
    pw: 'X9j2TKYy@cE6sSQD'
  };

  config.xtransit = {
    server: 'ws://172.16.4.109:9092',
    appId: 2,
    appSecret: '103981eb5b7781fedea116ece0ee00ac'
  };

  config.customLogger = {
    linkLogger: {
      file: '/zyz_logs/web-server/link-log.log',
      formatter(meta) {
        return `[${meta.level}] [${meta.date}] ${meta.message}`;
      },
    },
  };

  config.logrotator = {
    filesRotateBySize: [
      '/zyz_logs/web-server/link-log.log',
    ],
    maxFileSize: 1024,
  };


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