Repository URL to install this package:
|
Version:
1.2.17 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.axios = exports.setConfig = exports.getDefaultParams = exports.config = void 0;
var _axios = _interopRequireDefault(require("axios"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* @todo @important 0. make these env params externally configurable <<<<<<<<<<<
*/
// import { defineFinal, asyncWrap } from 'chain-able-boost'
const config = new Map();
exports.config = config;
const setConfig = x => {
Object.keys(x).forEach(key => config.set(x, key));
};
exports.setConfig = setConfig;
const storeId = process.env.SHOULD_USE_LOWERCASE_STORE_ID ? 'storeid' : 'storeId';
const getDefaultParams = () => {
if (config.has('defaultParams') === 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;
const axiosInstance = _axios.default.create({
baseUrl: process.env.BASE_URL || 'http://localhost:4000'
}); // const GET = asyncWrap(axiosInstance.get)
// const POST = asyncWrap(axiosInstance.post)
// const AXIOSER = asyncWrap(axiosInstance)
// const FETCHREQUEST = asyncWrap(axiosInstance.request)
// defineFinal(GET, 'methodName', 'GET')
// defineFinal(POST, 'methodName', 'POST')
// defineFinal(AXIOSER, 'methodName', 'AXIOSER')
// defineFinal(FETCHREQUEST, 'methodName', 'REQUEST')
// config.set('POST', POST)
// config.set('FETCHREQUEST', FETCHREQUEST)
exports.axios = axiosInstance;