Repository URL to install this package:
|
Version:
7.1.2-patch-delete ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const config = new Map();
exports.config = config;
const setConfig = x => {
Object.keys(x).forEach(key => config.set(x, key));
};
exports.setConfig = setConfig;
if (process.env.ONE_REQUEST_BASE_URL === 'undefined' ||
!process.env.ONE_REQUEST_BASE_URL) {
process.env.ONE_REQUEST_BASE_URL = 'http://localhost:4000';
}
const baseURL = process.env.ONE_REQUEST_BASE_URL;
config.set('baseUrl', baseURL);
config.set('shouldEncodeGetWithFormBody', process.env.NODE_ENV !== 'test');
config.set('defaultCache', { ttl: 30 });
const logger = {
warn: console.warn,
error: console.error,
info: console.info,
debug: console.debug,
};
const defaultContext = Object.freeze({
// @todo name `logger`?
log: logger,
});
config.set('logger', logger);
config.set('defaultContext', defaultContext);
const storeId = process.env.SHOULD_USE_LOWERCASE_STORE_ID
? 'storeid'
: 'storeId';
const getDefaultParams = () => {
if (config.has('constantParams') === false) {
const defaultParams = {
partnerId: config.get('partnerId'),
campaignId: config.get('campaignId'),
[storeId]: config.get('storeId'),
// appid: config.get('appid'),
locale: config.get('locale'),
};
config.set('defaultParams', defaultParams);
}
return config.get('defaultParams');
};
exports.getDefaultParams = getDefaultParams;
//# sourceMappingURL=config.js.map