@vara/custom-logic-sdk
Version:
Server Side JavaScript SDK for Custom Business Logic
30 lines (22 loc) • 916 B
JavaScript
/**
* Created by stevenchin on 2/13/17.
*/
const envConfig = require('../../config/environment/env-config');
const constants = require('../constants/constants');
const { TX_API_PATHS } = constants;
const standaloneFnSvc = {};
/**
* Generates the Etx API url for executing a standalone function
* @param name {String}
* @param [options] {Object}
* @param [options.usePublicUrl] {Boolean} - allows callers to use the public Etx API url instead of the internal one (default behavior)
* @returns {String} - Etx API url for executing a standalone function
*/
standaloneFnSvc.generatePlatformUrl = function generatePlatformUrl(name, options = { usePublicUrl: false }) {
let apiBaseUrl = envConfig.TX_API_INTERNAL_URL;
if (options.usePublicUrl) {
apiBaseUrl = envConfig.TX_API_PUBLIC_URL;
}
return `${apiBaseUrl}${TX_API_PATHS.STANDALONE_FUNCTIONS}/${name}`;
};
module.exports = standaloneFnSvc;