How to use the @clevercloud/client/cjs/api/application.js.getFavouriteDomain function in @clevercloud/client

To help you get started, we’ve selected a few @clevercloud/client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CleverCloud / clever-tools / src / models / domain.js View on Github external
async function getBest (appId, orgaId) {
  Logger.debug('Trying to get the favourite vhost for ' + appId);
  return getFavouriteDomain({ id: orgaId, appId }).then(sendToApi)
    .catch(async (e) => {

      if (e.status !== 404) {
        throw e;
      }

      Logger.debug('No favourite vhost defined for ' + appId + ', selecting the best one');
      const allDomains = await getAllDomains({ id: orgaId, appId }).then(sendToApi);
      const result = selectBest(allDomains);

      if (result == null) {
        throw new Error(`Couldn't find a domain name`);
      }

      return result;
    });