/**
* env service
*
* @author lizh
*
*/

class Environment {
  constructor() {
  }

  static get DEVELOPMENT_MODE() {
    return 'development'
  }
  static get LOCAL_MODE() {
    return 'local-dev'
  }
  static get STAGE_MODE() {
    return 'stage'
  }

  static get PRODUCTION_MODE() {
    return 'production'
  }

  static get TEST_MODE() {
    return 'test'
  }

  static get DEMO_MODE() {
    return 'demo'
  }
  
	static get BENCHMARK_MODE() {
    return 'benchmark'
  }

  setServerMode(mode) {
    if (!mode) {
      this.mode = Environment.DEVELOPMENT_MODE
      return
    }

    mode = mode.toLowerCase();
    if (mode !== Environment.LOCAL_MODE &&
      mode !== Environment.DEVELOPMENT_MODE &&
      mode !== Environment.PRODUCTION_MODE &&
      mode !== Environment.TEST_MODE &&
      mode !== Environment.DEMO_MODE &&
      mode !== Environment.STAGE_MODE &&
			mode !== Environment.BENCHMARK_MODE) {
				throw Error(`Invalid environemnt mode - "${mode}", the supported mode should be "development", "production" or "stage", "demo", "benchmark"`)
    }
    this.mode = mode
  }

  getServerMode() {
    return this.mode
  }
};

module.exports = new Environment();
