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    
@skava/graphql / src / deps / transformRequestProxy.ts
Size: Mime:
import express from 'express'
import { Cookie, CookieJar } from 'tough-cookie'
import { isArray, isObj, isTrue, isEmpty } from 'uxui-modules/exotic'
import * as config from '../bootstrapper/api/config'
import { getStreamDataAccessObjType } from '../bootstrapper/api/STREAMDAO'

// const cookieJar = new CookieJar()
// @TODO change the base url & config ^
// @NOTE we would want the proxies if we want the production
// so when we merge into master or when we have the flag
// then test on real api responses - best of both
// if (!ENV_TEST || ENV_API_PROD) {
//   // change the config
// }

const { clientDomain, clientVersion, cookieConfig } = config
const apiConfig = { clientDomain, clientVersion }

const https = 'https'
const baseUrlPrefix = `${https}://${clientDomain}/skavastream`

const getBaseTargetURL = (objectDAO, callType) => {
    /* @TODO Sort this out properly as proxy is broken  */
    let targetUrl = ''
    const version = objectDAO.clientVersion ? objectDAO.clientVersion : apiConfig.clientVersion
    if (objectDAO.isAbsoluteUrl) {
        targetUrl = objectDAO['absoluteUrl']
    } else {
        targetUrl = `${baseUrlPrefix}/${objectDAO.type}/${version}/${objectDAO.partner}`
    }

    return targetUrl || 'https://@@FAIL'
}

const getURL = (route, callType) => {
    const type = route.replace('/', '')
    const objectDAO = getStreamDataAccessObjType(type)
    const target = getBaseTargetURL(objectDAO, callType)
    return target
}

const endpoints = [
    '/productlist',
    '/category',
    '/product',
    '/viewbag',
    '/getlists',
    '/profile',
    '/search',
    '/reviews',
    '/getstores',
    '/register',
    '/createlist',
    '/additem',
    '/deleteitem',
    '/getitems',
    '/login',
    '/profile',
    '/logout',
    '/setshippingaddress/update',
    '/setpaymentmethod',
    '/deletecard',
    '/submitreview',
    '/resetpassword',
    '/orderdetails',
    '/submitorder/return',
    '/submitorder/cancel',
    '/addtobag',
    '/deletefrombag',
    '/estimate',
    '/updatebag',
    '/updateshippingmethods',
    '/payment',
    '/submitorder',
    '/setshippingaddress',
    '/searchsuggestion',
    '/updatepassword',
    '/getsecurityquestion',
    '/suspendcart',
    '/user',
    '/getCatalog',
    '/getPages',
    '/getKeyForToken',
    '/loyalty',
    '/checkoutauth',
    '/token/create',
]
const callDetails = {
    '/productlist': 'GET',
    '/category': 'GET',
    '/product': 'GET',
    '/viewbag': 'GET',
    '/getlists': 'POST',
    '/profile': 'POST',
    '/search': 'GET',
    '/reviews': 'POST',
    '/submitreview': 'POST',
    '/getstores': 'POST',
    '/register': 'POST',
    '/additem': 'POST',
    '/deleteitem': 'POST',
    '/getitems': 'POST',
    '/login': 'POST',
    '/logout': 'POST',
    '/setshippingaddress/update': 'POST',
    '/setpaymentmethod': 'POST',
    '/deletecard': 'POST',
    '/resetpassword': 'POST',
    '/orderdetails': 'POST',
    '/submitorder/return': 'POST',
    '/submitorder/cancel': 'POST',
    '/addtobag': 'POST',
    '/deletefrombag': 'POST',
    '/estimate': 'POST',
    '/updatebag': 'POST',
    '/updateshippingmethods': 'POST',
    '/payment': 'POST',
    '/submitorder': 'POST',
    '/setshippingaddress': 'POST',
    '/searchsuggestion': 'GET',
    '/suspendcart': 'POST',
    '/user': 'GET',
    '/getCatalog': 'GET',
    '/getPages': 'GET',
    '/getKeyForToken': 'GET',
    '/loyalty': 'POST',
    '/checkoutauth': 'POST',
    '/token/create': 'POST',
}

Object.freeze(endpoints)
Object.freeze(callDetails)

export { apiConfig, https, baseUrlPrefix, getBaseTargetURL, getURL, endpoints, callDetails }