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:zyzSQ2022@dds-8vb9e0b130444f341.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb9e0b130444f342.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-510195956', // 内网
    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-8vbq8kgkeqd4bbegwk.redis.zhangbei.rds.aliyuncs.com', // 内网
    pw: 'bB^Ow3l@RMRSTtJU'
  };


  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,
  };
};
