synapse-react-client
Version:
[](https://travis-ci.com/Sage-Bionetworks/Synapse-React-Client) [](https://badge.fury.io/js/synaps
37 lines • 1.85 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEndpoint = exports.PRODUCTION_ENDPOINT_CONFIG = exports.getSynapsePortalEndpoint = exports.BackendDestinationEnum = void 0;
var BackendDestinationEnum;
(function (BackendDestinationEnum) {
BackendDestinationEnum[BackendDestinationEnum["REPO_ENDPOINT"] = 0] = "REPO_ENDPOINT";
BackendDestinationEnum[BackendDestinationEnum["PORTAL_ENDPOINT"] = 1] = "PORTAL_ENDPOINT";
})(BackendDestinationEnum = exports.BackendDestinationEnum || (exports.BackendDestinationEnum = {}));
var KNOWN_SYNAPSE_ORG_URLS = ['www.synapse.org', 'staging.synapse.org', 'tst.synapse.org', '127.0.0.1'];
var getSynapsePortalEndpoint = function (hostname) {
return KNOWN_SYNAPSE_ORG_URLS.includes(hostname.toLowerCase()) ? '/' : 'https://www.synapse.org/';
};
exports.getSynapsePortalEndpoint = getSynapsePortalEndpoint;
var DEFAULT_SYNAPSE_PORTAL = (0, exports.getSynapsePortalEndpoint)(window.location.hostname);
exports.PRODUCTION_ENDPOINT_CONFIG = {
REPO: 'https://repo-prod.prod.sagebase.org',
PORTAL: DEFAULT_SYNAPSE_PORTAL,
};
// Given an endpoint will return the specific stack object
var getEndpoint = function (endpoint) {
var endpoint_config = exports.PRODUCTION_ENDPOINT_CONFIG;
// @ts-ignore if overriding endpoint config
if (window.SRC && window.SRC.OVERRIDE_ENDPOINT_CONFIG) {
// @ts-ignore
endpoint_config = window.SRC && window.SRC.OVERRIDE_ENDPOINT_CONFIG;
}
var PORTAL = endpoint_config.PORTAL, REPO = endpoint_config.REPO;
if (!PORTAL || !REPO) {
throw Error('Error failed to specify endpoints, cannot make call');
}
if (endpoint === BackendDestinationEnum.PORTAL_ENDPOINT) {
return PORTAL;
}
return REPO;
};
exports.getEndpoint = getEndpoint;
//# sourceMappingURL=getEndpoint.js.map