Endpoint Refactor - Extracting getProtocol
const getProtocol = (service, isServerSide, environment) => { | |
if (service === 'webclient') { | |
if (isServerSide) { | |
return 'http' | |
} | |
return 'https' | |
} else { | |
if (environment === 'local') { | |
return 'http' | |
} else { | |
if (isServerSide) { | |
return 'http' | |
} else { | |
return 'https' | |
} | |
} | |
} | |
} | |
function endpoint(service, version = '') { | |
const protocol = getProtocol(service, __SERVER__, __ENV__) | |
// Rest of the mess here | |
... | |
const url = `${protocol}://${domain}` | |
return url | |
} | |
export default endpoint |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment