Files
old-ribica/front-api/app.rb

33 lines
702 B
Ruby

require 'sinatra'
require 'sinatra/activerecord'
require './config'
require 'json'
require 'sinatra/cookies'
Dir[File.dirname(__FILE__) + '/models/*.rb'].each {|file| require file }
set :bind, '0.0.0.0'
before do
content_type :json
# TODO: before running to production change this so that only specific
# domain is allowed
headers 'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Methods' => ['OPTIONS', 'GET', 'POST']
request.body.rewind
json_string = request.body.read
@json_params = JSON.parse json_string if json_string.length > 1
end
helpers Sinatra::Cookies
Dir[File.dirname(__FILE__) + '/controllers/*.rb'].each {|file| require file }