common.js 10.4 KB
/**
 * 系统配置
 *
 * @author hbomb qiqi.zhou@yoho.cn
 * @date 2016/05/06
 */

const pkg = require('../package.json');
const from = require('./from');

const isProduction = process.env.NODE_ENV === 'production';
const isTest = process.env.NODE_ENV === 'test';

const domains = {

    // api: 'http://api.yoho.cn/',
    // service: 'http://service.yoho.cn/',
    // liveApi: 'http://testapi.live.yohops.com:9999/',
    // singleApi: 'http://api-test3.yohops.com:9999/',

    // gray
    // api: 'http://apigray.yoho.cn/',
    // service: 'http://apigray.yoho.cn/',

    // platformApi: 'http://172.16.6.210:8088/',

    api: 'http://api-test3.dev.yohocorp.com/',
    service: 'http://api-test3.dev.yohocorp.com/',
    liveApi: 'http://testapi.live.yohops.com:9999/',
    singleApi: 'http://api-test3.dev.yohocorp.com/',

    imSocket: 'ws://socket.yohobuy.com:10240',
    imCs: 'http://im.yohobuy.com/api',
    global: 'http://api-global.yohobuy.com',
    store: 'http://192.168.102.47:8080/portal-gateway/',

    platformApi: 'http://192.168.102.48:8088/',
    extstore: 'http://extstore-test1.yohops.com',
    yohoNowApi: 'http://yohonow-test.yohops.com:9999/'
};

module.exports = {
    app: 'h5',
    appVersion: '6.6.0', // 调用api的版本
    appName: 'yohobuywap-node',
    port: 6001,
    siteUrl: '//m.yohobuy.com',
    assetUrl: '//127.0.0.1:5001',
    testCode: 'yoho4946abcdef#$%&!@',
    domains: domains,
    signExtend: {
        business_line: 'yohobuy'
    },
    report: {
        host: 'badjs.yoho.cn',
        port: 80,
        db: 'web-apm'
    },
    subDomains: {
        host: '.m.yohobuy.com',
        default: '//m.yohobuy.com',
        guang: '//guang.m.yohobuy.com',
        list: '//list.m.yohobuy.com',
        search: '//search.m.yohobuy.com',
        huodong: '//huodong.m.yohobuy.com',
        activity: '//activity.yohobuy.com',
        index: '//m.yohobuy.com'
    },
    useCache: false,
    loggers: {
        infoFile: {
            close: true,
            name: 'info',
            level: 'info',
            filename: 'logs/info.log',
            maxFiles: 1,
            tailable: true,
            maxsize: Math.pow(1024, 3),
            timestamp() {
                return new Date().toString();
            }
        },
        errorFile: {
            close: true,
            name: 'error',
            level: 'error',
            filename: 'logs/error.log',
            maxFiles: 1,
            tailable: true,
            maxsize: Math.pow(1024, 3),
            handleExceptions: true,
            timestamp() {
                return new Date().toString();
            }
        },
        console: {
            level: 'debug',
            colorize: 'all',
            prettyPrint: true,
            debugStdout: true
        }
    },
    zookeeperServer: '127.0.0.1:2181',
    alipayConfig: {
        payUrl: 'https://mapi.alipay.com/gateway.do',
        service: 'alipay.wap.create.direct.pay.by.user',
        partner: '2088701661478015',
        inputCharset: 'utf-8',
        notifyUrl: domains.service + 'payment/alipay_notify',
        returnUrl: '/shopping/pay/aliwapreturn',
        signType: 'MD5',
        paymentType: '1',
        alipayKey: 'kcxawi9bb07mzh0aq2wcirsf9znusobw',
        sellerMail: 'zfb@yoho.cn',
        merchantUrl: 'http://m.yohobuy.com/home/orderDetail?order_code='
    },
    WxPayConfig: {
        appId: 'wx75e5a7c0c88e45c2',
        mchId: '1227694201',
        key: '7e6f3307b64cc87c79c472814b88f7fb',
        appSecret: 'ce21ae4a3f93852279175a167e54509b',
        notifyUrl: domains.service + 'payment/weixin_notify',
    },
    geetestJs: '//static.geetest.com/static/tools/gt.js',
    jsSdk: '//cdn.yoho.cn/js-sdk/1.3.1/jssdk.js',
    redis: {
        connect: {
            host: '192.168.102.49',

            // host: '127.0.0.1',
            port: '6379',
            password: '',
            enable_offline_queue: false,
            retry_strategy(options) {
                if (options.error && options.error.code === 'ECONNREFUSED') {
                    console.log('connect redis server fail');
                }

                if (options.attempt < 10) {
                    return Math.min(options.attempt * 100, 1000);
                } else if (options.attempt > 10 && options.attempt < 100) {
                    return 1000;
                } else {
                    return 1000 * 10;
                }
            }
        },
        session: {
            host: '127.0.0.1',
            port: '6379',
            pass: '',
            prefix: 'yohobuy_session:'
        }
    },
    REQUEST_LIMIT: {
        // 10s 最多访问20次
        10: 20,

        // 30s 最多访问40次
        30: 40,

        // 60s 最多访问60次
        60: 60,

        // 100s 最多访问200次
        600: 200
    },
    LIMITER_IP_TIME: 3600, // 超出访问限制ip限制访问1小时
    superCapture: '93c70db61fe276f93ce781ad17dc47cd',
    from: from
};

if (isProduction) {
    Object.assign(module.exports, {
        assetUrl: `//cdn.yoho.cn/yohobuywap-node/${pkg.version}/`,
        domains: {
            api: 'http://api.yoho.yohoops.org/',
            service: 'http://api.yoho.yohoops.org/',
            global: 'http://api-global.yohobuy.com',
            store: 'http://openstore.yohobuy.com',
            liveApi: 'http://api.live.yoho.cn/',
            imSocket: 'wss://imsocket.yohobuy.com:443',
            imCs: 'https://imhttp.yohobuy.com/api',
            platformApi: 'http://api.platform.yohoops.org',
            extstore: 'http://extstore.yohobuy.com',
            yohoNowApi: 'http://new.yohoboys.com/'
        },
        useCache: true,
        zookeeperServer: 'web.zookeeper.yohoops.org:2181',
        alipayConfig: {
            payUrl: 'https://mapi.alipay.com/gateway.do',
            service: 'alipay.wap.create.direct.pay.by.user',
            partner: '2088701661478015',
            inputCharset: 'utf-8',
            notifyUrl: 'http://service.yoho.cn/payment/alipay_notify',
            returnUrl: '/shopping/pay/aliwapreturn',
            signType: 'MD5',
            paymentType: '1',
            alipayKey: 'kcxawi9bb07mzh0aq2wcirsf9znusobw',
            sellerMail: 'zfb@yoho.cn',
            merchantUrl: 'http://m.yohobuy.com/home/orderDetail?order_code='
        },
        WxPayConfig: {
            appId: 'wx75e5a7c0c88e45c2',
            mchId: '1227694201',
            key: '7e6f3307b64cc87c79c472814b88f7fb',
            appSecret: 'ce21ae4a3f93852279175a167e54509b',
            notifyUrl: 'http://service.yoho.cn/payment/weixin_notify',
        },
        redis: {
            connect: {
                host: 'redis.web.yohoops.org',
                port: '6379',
                password: 'redis9646',
                enable_offline_queue: false,
                retry_strategy(options) {
                    if (options.error && options.error.code === 'ECONNREFUSED') {
                        console.log('connect redis server fail');
                    }

                    if (options.attempt < 10) {
                        return Math.min(options.attempt * 100, 1000);
                    } else if (options.attempt > 10 && options.attempt < 100) {
                        return 1000;
                    } else {
                        return 1000 * 10;
                    }
                }
            },
            session: {
                host: 'redis.web.yohoops.org',
                port: '6379',
                pass: 'redis9646',
                prefix: 'yohobuy_session:'
            }
        },
        report: {
            host: 'badjs.yoho.cn',
            port: 80,
            db: 'web-apm'
        },
        loggers: {
            infoFile: {
                name: 'info',
                level: 'info',
                filename: '/Data/logs/yoho-yohobuy-wap/info/info.log',
                maxFiles: 1,
                tailable: true,
                maxsize: Math.pow(1024, 3),
                timestamp() {
                    return new Date().toString();
                }
            },
            errorFile: {
                name: 'error',
                level: 'error',
                filename: '/Data/logs/yoho-yohobuy-wap/error/error.log',
                maxFiles: 1,
                tailable: true,
                maxsize: Math.pow(1024, 3),
                handleExceptions: true,
                timestamp() {
                    return new Date().toString();
                }
            },
            console: {
                close: true,
                level: 'info',
                colorize: 'all',
                prettyPrint: true,
                debugStdout: true
            }
        }
    });
} else if (isTest) {
    Object.assign(module.exports, {
        assetUrl: `//cdn.yoho.cn/yohobuywap-node/${pkg.version}/`,
        domains: {
            api: process.env.TEST_API || 'http://api-test1.yohops.com:9999/',
            service: process.env.TEST_API || 'http://api-test1.yohops.com:9999/',
            global: process.env.TEST_GLOBAL || 'http://global-test-soa.yohops.com:9999/',
            store: process.env.TEST_STORE || 'http://192.168.102.210:8080/portal-gateway/wechat/',
            liveApi: process.env.TEST_LIVE || 'http://testapi.live.yohops.com:9999/',
            imSocket: process.env.TEST_IM_SOCKET || 'ws://socket.yohobuy.com:10240',
            imCs: process.env.TEST_IM_CS || 'http://im.yohobuy.com/api',
            platformApi: 'http://192.168.102.48:8088/',
            extstore: 'http://extstore-test1.yohops.com',
            yohoNowApi: process.env.YOHO_NOW_API || 'http://yohonow-test.yohops.com:9999/'
        },
        useCache: true,
        alipayConfig: {
            payUrl: 'https://mapi.alipay.com/gateway.do',
            service: 'alipay.wap.create.direct.pay.by.user',
            partner: '2088701661478015',
            inputCharset: 'utf-8',
            notifyUrl: (process.env.TEST_SERVICE || 'http://service-test1.yohops.com:9999/') + 'payment/alipay_notify',
            returnUrl: '/shopping/pay/aliwapreturn',
            signType: 'MD5',
            paymentType: '1',
            alipayKey: 'kcxawi9bb07mzh0aq2wcirsf9znusobw',
            sellerMail: 'zfb@yoho.cn',
            merchantUrl: 'http://m.yohobuy.com/home/orderDetail?order_code='
        },
        WxPayConfig: {
            appId: 'wx75e5a7c0c88e45c2',
            mchId: '1227694201',
            key: '7e6f3307b64cc87c79c472814b88f7fb',
            appSecret: 'ce21ae4a3f93852279175a167e54509b',
            notifyUrl: (process.env.TEST_SERVICE || 'http://service-test1.yohops.com:9999/') + 'payment/weixin_notify',
        }
    });
}