all files / src/ config.js

100% Statements 34/34
100% Branches 14/14
100% Functions 10/10
100% Lines 6/6
4 statements, 2 functions, 6 branches Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53                                                                        80×               82×          
import clone from 'lodash/clone';
 
let defaultConfig = {
  allowHttp: false
};
 
let config = clone(defaultConfig);
 
/**
 * Global config class.
 *
 * Usage node:
 * ```
 * import {Config} from 'rover-sdk';
 * Config.setAllowHttp(true);
 * ```
 *
 * Usage browser:
 * ```
 * RoverSdk.Config.setAllowHttp(true);
 * ```
 * @static
 */
class Config {
  /**
   * Sets `allowHttp` flag globally. When set to `true`, connections to insecure http protocol servers will be allowed.
   * Must be set to `false` in production. Default: `false`.
   * @param {boolean} value
   * @static
   */
  static setAllowHttp(value) {
    config.allowHttp = value;
  }
 
  /**
   * Returns the value of `allowHttp` flag.
   * @static
   */
  static isAllowHttp() {
    return clone(config.allowHttp);
  }
 
  /**
   * Sets all global config flags to default values.
   * @static
   */
  static setDefault() {
    config = clone(defaultConfig);
  }
}
 
export {Config};