Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
Object.defineProperty(exports, "asyncWrap", {
  enumerable: true,
  get: function get() {
    return _index.asyncWrap;
  }
});
exports.axios = exports.FETCHREQUEST = exports.AXIOSER = exports.POST = exports.GET = exports.setConfig = exports.getDefaultParams = exports.config = void 0;

var _axios = _interopRequireDefault(require("axios"));

var _index = require("../chain-able/index.js");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
 * @todo @important 0. make these env params externally configurable <<<<<<<<<<<
 */
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'
});

exports.axios = axiosInstance;
const GET = (0, _index.asyncWrap)(axiosInstance.get);
exports.GET = GET;
const POST = (0, _index.asyncWrap)(axiosInstance.post);
exports.POST = POST;
const AXIOSER = (0, _index.asyncWrap)(axiosInstance);
exports.AXIOSER = AXIOSER;
const FETCHREQUEST = (0, _index.asyncWrap)(axiosInstance.request);
exports.FETCHREQUEST = FETCHREQUEST;
(0, _index.defineFinal)(GET, 'methodName', 'GET');
(0, _index.defineFinal)(POST, 'methodName', 'POST');
(0, _index.defineFinal)(AXIOSER, 'methodName', 'AXIOSER');
(0, _index.defineFinal)(FETCHREQUEST, 'methodName', 'REQUEST');
config.set('POST', POST);
config.set('FETCHREQUEST', FETCHREQUEST);