2015-06-18 06:58:58 +08:00
|
|
|
Actions = require './onboarding-actions'
|
|
|
|
NylasStore = require 'nylas-store'
|
|
|
|
|
|
|
|
class NylasApiEnvironmentStore extends NylasStore
|
|
|
|
constructor: ->
|
|
|
|
@listenTo Actions.changeAPIEnvironment, @_setEnvironment
|
2015-10-03 06:01:26 +08:00
|
|
|
@_setEnvironment('production') unless atom.config.get('env')
|
2015-06-18 06:58:58 +08:00
|
|
|
|
2015-10-03 06:01:26 +08:00
|
|
|
getEnvironment: ->
|
|
|
|
atom.config.get('env')
|
2015-06-18 06:58:58 +08:00
|
|
|
|
|
|
|
_setEnvironment: (env) ->
|
2015-07-09 04:25:11 +08:00
|
|
|
throw new Error("Environment #{env} is not allowed") unless env in ['development', 'experimental', 'staging', 'production']
|
2015-06-18 06:58:58 +08:00
|
|
|
atom.config.set('env', env)
|
|
|
|
@trigger()
|
|
|
|
|
|
|
|
module.exports = new NylasApiEnvironmentStore()
|