@sap-cloud-sdk/connectivity
Version:
SAP Cloud SDK for JavaScript connectivity
27 lines • 1.23 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertHttpDestination = assertHttpDestination;
exports.isHttpDestination = isHttpDestination;
/**
* Assertion that the Destination is a HttpDestination.
* This method comes in handy when you retrieved a destination from the destination service and need to check if it is a HttpDestination.
* @param destination - Destination or HttpDestination.
*/
function assertHttpDestination(destination) {
if (!isHttpDestination(destination)) {
throw new Error(destination.url
? `The 'type' property is ${destination.type} instead of HTTP for destination '${destination.name}' which is mandatory if you use it as an 'HTTP destination`
: `The 'url' property is not set for destination ${destination.name} which is mandatory if you use it as an 'HTTP destination`);
}
}
/**
* Type guard to find if object is a Destination.
* @param destination - Destination to be checked.
* @returns Boolean.
*/
function isHttpDestination(destination) {
return (!!destination &&
!!destination.url &&
(!destination.type || destination.type === 'HTTP'));
}
//# sourceMappingURL=destination-service-types.js.map