Esempio n. 1
0
  _updateCachedTenant(alias, err => {
    if (err) {
      log().error({ err, cmd, alias }, 'An error occurred while refreshing a tenant after update');
    }

    TenantsAPI.emit(cmd, getTenant(alias));
  });
});

/*!
 * Listen for configuration update events. If a tenant is made public or private, we need to update
 * their cached status in the tenantsNotInteractable cache
 */
ConfigAPI.eventEmitter.on('update', alias => {
  return _updateCachedTenant(alias);
});

/**
 * Initialize the middleware that will put the tenant object onto the request and cache all of the registered
 * tenants
 *
 * @param  {Object}         serverConfig        Server configuration object containing global admin tenant information
 * @param  {Function}       callback            Standard callback function
 * @param  {Object}         callback.err        An error that occurred, if any
 */
const init = function(_serverConfig, callback) {
  // Cache the server configuration
  serverConfig = _serverConfig;

  // This middleware adds the tenant to each request on the global admin server
Esempio n. 2
0
    }

    // Ensure the skins are not cached, as they may be invalid now
    cachedSkins = {};

    // Cache the i18n bundles
    return _cacheI18nKeys(callback);
  });
};

ConfigAPI.eventEmitter.on('update', tenantAlias => {
  // Re-generate the skin.
  // Don't delete it from the cache just yet as we might still be serving requests.
  _generateSkin(tenantAlias, err => {
    if (err) {
      log().error({ err, tenantAlias }, 'Could not re-cache the tenant skin after a config update.');
    }

    emitter.emit('skinParsed');
  });
});

/// //////////
// Caching //
/// //////////

/**
 * When a file in the UI repository has changed, we update the static file cache by deleting
 * the record for that file if there is one. The next time the updated/created file will be
 * re-requested, caching will be attempted again. We also check if the changed file is a
 * widget manifest file, and refresh the widget manifest cache if that's the case