class Fanforce::App::Sinatra get '/internals/config.json' do file = File.open("#{Fanforce::App.base_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.base_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