Created
December 6, 2019 16:05
-
-
Save D7Torres/e0465618cb24f4a138fd20bf37ff4cda to your computer and use it in GitHub Desktop.
Endpoint Refactor - Extracting getProtocol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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