Sha256: 84c0de4e3532cfd2670c2bb639751d7681e5d246cc47da476ee19fe3c6654a66

Contents?: true

Size: 983 Bytes

Versions: 2

Compression:

Stored size: 983 Bytes

Contents

class Fanforce::App::Sinatra

  get '/internals/config.json' do
    file = File.open("#{Fanforce::App.root_dir}/config.json")
    config = MultiJson.load(file.read, symbolize_keys: true)
    config[:iron_workers] ||= []

    config[:iron_workers].each do |iron_worker|
      iron_worker[:token] = ENV['IRON_TOKEN']
      iron_worker[:project_id] = ENV['IRON_PROJECT_ID']
    end

    config.to_json
  end

  post '/internals/config.json' do
    filename = "#{Fanforce::App.root_dir}/config.json"
    file = File.open(filename)
    old_config = MultiJson.load(file.read, symbolize_keys: true)
    new_config = MultiJson.load(params[:config], symbolize_keys: true)
    raise 'IUIDs do not match' if old_config[:_iuid] and old_config[:_iuid] != new_config[:_iuid]

    File.open(filename, 'w') {|f| f.write(JSON.pretty_generate(Hash[new_config.sort])) }
    json status: 'finished'
  end

  get '/app_factory/directives/:filename' do
    factory_directive(params[:filename])
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fanforce-app-factory-2.0.0.rc5 lib/fanforce/app_factory/Routes.rb
fanforce-app-factory-2.0.0.rc4 lib/fanforce/app_factory/Routes.rb