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

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

  // add your special config in here  
  
  config.mongoose = {
    url: 'mongodb://dbop:zyzSQ42022@dds-8vb11ca8d5e88fd41.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb11ca8d5e88fd42.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-510489410', // 内网
    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-8vb9q6zk7bpcvo456g.redis.zhangbei.rds.aliyuncs.com', // 内网
    pw: 'X9j2TKYy@cE6sSQD'
  };

  config.xtransit = {
    server: 'ws://172.16.4.109:9092',
    appId: 5,
    appSecret: '4441a80f2516a879fa3e4c7c096ab4f1'
  };

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

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

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