-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapplication.rb
More file actions
48 lines (37 loc) · 931 Bytes
/
Copy pathapplication.rb
File metadata and controls
48 lines (37 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require 'sinatra/base'
require 'sinatra/reloader'
require 'sinatra/json'
class Application < Sinatra::Base
configure do
$LOAD_PATH << "#{File.dirname(__FILE__)}/lib"
end
configure :development do
register Sinatra::Reloader
require 'better_errors'
use BetterErrors::Middleware
BetterErrors.application_root = __dir__
BetterErrors.use_pry!
require 'dotenv'
Dotenv.load
end
configure :production do
require 'newrelic_rpm'
end
require 'ruby_meetup'
RubyMeetup::ApiKeyClient.key = ENV['MEETUP_API_KEY']
require 'haml'
require 'group'
require 'event_raffler'
get '/' do
haml :index
end
post '/events' do
json Group.new(params[:name]).events
end
get '/event/:id' do
haml :event, locals: { event: EventRaffler.new(params[:id]) }
end
post '/raffle' do
json EventRaffler.new(params[:event]).raffle(params[:number], params[:reject])
end
end