-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.ru
144 lines (118 loc) · 3.7 KB
/
config.ru
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#\ -q
require "bundler/setup"
require "hanami/api"
require "hanami/middleware/body_parser"
require "sentry-ruby"
require "rack/jwt/auth"
require "rack/jwt"
require "rack/runtime"
require "./initializers/config"
require "./initializers/sentry_config"
require "./initializers/jwt"
require "./initializers/env"
require "./rack/app_store_connect_headers"
require "./rack/app_store_auth_handler"
require "./rack/internal_error_handler"
require "./rack/rack_ougai_logger"
require "./lib/app_store/connect"
require "./lib/internal"
class InternalApp < Hanami::API
get "keys" do
json(Internal.keys(params))
end
end
class AppleAppV1 < Hanami::API
use Rack::JWT::Auth, Initializers::JWT.options
use Rack::AppStoreConnectHeaders
use Rack::AppStoreAuthHandler
use Rack::InternalErrorHandler
DOMAIN = AppStore::Connect
helpers do
def not_found(message)
halt(404, json({error: message}))
end
end
scope "apps/:bundle_id" do
get "/" do
json(DOMAIN.metadata(**env[:app_store_connect_params].merge(params)))
end
get "current_status" do
json(DOMAIN.current_app_info(**env[:app_store_connect_params].merge(params)))
end
scope "builds" do
get ":build_number" do
json(DOMAIN.build(**env[:app_store_connect_params].merge(params)))
end
get "latest" do
json(DOMAIN.latest_build(**env[:app_store_connect_params].merge(params)))
end
patch ":build_number" do
DOMAIN.update_build_notes(**env[:app_store_connect_params].merge(params))
status(204)
end
end
scope "release" do
post "prepare" do
json(DOMAIN.prepare_release(**env[:app_store_connect_params].merge(params)))
end
patch "submit" do
DOMAIN.create_review_submission(**env[:app_store_connect_params].merge(params))
status(204)
end
patch "cancel_submission" do
json(DOMAIN.cancel_review_submission(**env[:app_store_connect_params].merge(params)))
end
patch "start" do
DOMAIN.start_release(**env[:app_store_connect_params].merge(params))
status(204)
end
get "/" do
json(DOMAIN.release(**env[:app_store_connect_params].merge(params)))
end
scope "live" do
get "/" do
json(DOMAIN.live_release(**env[:app_store_connect_params].merge(params)))
end
scope "rollout" do
patch "pause" do
json(DOMAIN.pause_phased_release(**env[:app_store_connect_params].merge(params)))
end
patch "resume" do
json(DOMAIN.resume_phased_release(**env[:app_store_connect_params].merge(params)))
end
patch "complete" do
json(DOMAIN.complete_phased_release(**env[:app_store_connect_params].merge(params)))
end
patch "halt" do
DOMAIN.halt_release(**env[:app_store_connect_params].merge(params))
status(204)
end
end
end
end
scope "groups" do
get "/" do
params[:internal] = params[:internal].nil? ? "nil" : params[:internal]
json(DOMAIN.groups(**env[:app_store_connect_params].merge(params)))
end
patch ":group_id/add_build" do
DOMAIN.send_to_group(**env[:app_store_connect_params].merge(params))
status(204)
end
end
end
end
class App < Hanami::API
include Initializers::Config
extend Initializers::Env
include Initializers::SentryConfig
use Rack::Ougai::Logger
use Rack::Ougai::RequestLogger
use Rack::Runtime
use Sentry::Rack::CaptureExceptions
use Hanami::Middleware::BodyParser, :json
get("ping") { "pong" }
mount AppleAppV1.new, at: "apple/connect/v1"
mount InternalApp.new, at: "internal" if development?
end
run App.new