Mailspring/internal_packages/onboarding/lib/nylas-api-environment-store.coffee

19 lines
619 B
CoffeeScript
Raw Normal View History

Actions = require './onboarding-actions'
NylasStore = require 'nylas-store'
class NylasApiEnvironmentStore extends NylasStore
constructor: ->
@listenTo Actions.changeAPIEnvironment, @_setEnvironment
defaultEnv = if atom.inDevMode() then 'staging' else 'staging'
@_setEnvironment(defaultEnv) unless atom.config.get('env')
getEnvironment: -> atom.config.get('env')
_setEnvironment: (env) ->
throw new Error("Environment #{env} is not allowed") unless env in ['development', 'staging', 'production']
atom.config.set('env', env)
@trigger()
module.exports = new NylasApiEnvironmentStore()