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

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

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

module.exports = {
    app: 'h5',
    appVersion: '5.8.0', // 调用api的版本
    port: 6006,
    assetUrl: `/yoho-activity-platform/${pkg.version}/`,
    domains: {
        api: 'http://api-test3.yohops.com:9999/',
        service: 'http://service-test3.yohops.com:9999/',
        singleApi: 'http://api-test3.yohops.com:9999/'
    },
    corsAllowOrigin: [
        'http://localhost:8081',
        'http://localhost:63342'
    ],
    useCache: false,
    memcache: {
        master: ['127.0.0.1:11211'],
        slave: ['127.0.0.1:11211'],
        session: ['127.0.0.1:11211'],
        timeout: 1000,
        retries: 0
    },
    interfaceShunt: {
        open: false
    },
    loggers: {
        infoFile: {
            close: true,
            name: 'info',
            level: 'error',
            filename: 'logs/info.log',
            maxFiles: 7
        },
        errorFile: {
            name: 'error',
            level: 'error',
            filename: 'logs/error.log',
            handleExceptions: true,
            maxFiles: 7
        },
        console: {
            level: 'info',
            colorize: 'all',
            prettyPrint: true
        }
    },
    mysql: {
        connect: {
            host: 'localhost',
            port: '3306',
            user: 'root',
            password: ''
        },
        database: 'yoho_activity_platform',
    },
    qiniu: {
        ACCESS_KEY: 'BwWhoJN536BnV3CzlE20AjNKC9O2bP0l5tFpKsDU',
        SECRET_KEY: '_x2VtO7fEmylgjojmLi7qwTBtRm30S8BrO0FxOPK',
        BUCKET_NAME: 'cmsimg01'
    },
    yohoSecret: '3bd815162342d9733f06ab6811082c64'
};

if (isProduction) {
    Object.assign(module.exports, {
        appName: 'm.yohobuy.com',
        assetUrl: `/yoho-activity-platform/${pkg.version}/`,
        domains: {
            api: 'http://api.yoho.yohoops.org/',
            service: 'http://service.yoho.yohoops.org/',
            global: 'http://api-global.yohobuy.com',
            liveApi: 'http://api.live.yoho.cn/',
            singleApi: 'http://single.yoho.cn/',
            platformApi: 'http://api.platform.yohoops.org'
        },
        corsAllowOrigin: [
            'http://ad.yoho.cn',
            'https://ad.yoho.cn',
            'http://feature.yoho.cn',
            'https://feature.yoho.cn',
            'https://huodong.yoho.cn'
        ],
        memcache: {
            master: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'],
            slave: ['memcache1.yohoops.org:12112', 'memcache2.yohoops.org:12112', 'memcache3.yohoops.org:12112'],
            session: ['memcache1.yohoops.org:12111', 'memcache2.yohoops.org:12111', 'memcache3.yohoops.org:12111'],
            poolSize: 100,
            reconnect: 5000,
            timeout: 1000,
            retries: 0
        },
        useCache: true,
        mysql: {
            connect: {
                host: '10.67.2.144',
                port: '3307',
                user: 'yh_vpc_bak',
                password: 'yoho@2Y$^YpNb7hp'
            },
            database: 'yoho_activity_platform',
        }
    });
} else if (isTest) {
    Object.assign(module.exports, {
        appName: 'm.yohobuy.com for test',
        assetUrl: `/yoho-activity-platform/${pkg.version}/`,
        domains: {
            api: process.env.TEST_API || 'http://api-test1.yohops.com:9999/',
            service: process.env.TEST_SERVICE || 'http://service-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/',
            liveApi: process.env.TEST_LIVE || 'http://testapi.live.yohops.com:9999/',
            singleApi: process.env.TEST_SINGLE || 'http://api-test1.yohops.com:9999/',
            platformApi: 'http://192.168.102.48:8088/'
        },
        memcache: {
            master: ['127.0.0.1:12111'],
            slave: ['127.0.0.1:12112'],
            session: ['127.0.0.1:12111'],
            timeout: 100,
            reconnect: 5000,
            retries: 0
        },
        useCache: true,
        mysql: {
            connect: {
                host: 'localhost',
                port: '3306',
                user: 'root',
                password: ''
            },
            database: 'yoho_activity_platform',
        }
    });
}