Repository URL to install this package:
|
Version:
1.2.19 ▾
|
/**
* @todo @important 0. make these env params externally configurable <<<<<<<<<<<
*/
import axios from 'axios'
// import { defineFinal, asyncWrap } from 'chain-able-boost'
const config = new Map()
const setConfig = x => {
Object.keys(x).forEach(key => config.set(x, key))
}
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')
}
const axiosInstance = axios.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)
export { config, getDefaultParams, setConfig }
// export { GET, POST, AXIOSER, FETCHREQUEST }
// export { asyncWrap }
export { axiosInstance as axios }