-
Notifications
You must be signed in to change notification settings - Fork 1
/
routes.jl
180 lines (167 loc) · 4.65 KB
/
routes.jl
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
using PkgVizBoard.DashboardController, PkgVizBoard.StatsController
using Genie, Stipple, StippleUI, StipplePlotly
using SwagUI, SwaggerMarkdown
#=== constants ==#
const ALL_REGIONS = "all"
const REGIONS = String[ALL_REGIONS, "au", "cn-east", "cn-northeast", "cn-southeast", "eu-central", "in", "jp", "kr", "sa", "sg", "us-east", "us-west"]
const DAY = "day"
const MONTH = "month"
const YEAR = "year"
#=== config ==#
if Genie.Configuration.isprod()
Genie.Assets.assets_config!([Genie, Stipple, StippleUI, StipplePlotly], host = "https://cdn.statically.io/gh/GenieFramework")
end
#== server ==#
route("/", PkgVizBoard.DashboardController.dashboard)
swagger"""
/api/v1/regions:
get:
summary: Get regions
description: Get regions
responses:
'200':
description: Returns a JSON object with all the regions
"""
route("/api/v1/regions", PkgVizBoard.StatsController.API.V1.regions, method = GET)
swagger"""
/api/v1/packages:
get:
summary: Get the list of packages
description: Get the list of packages
responses:
'200':
description: Returns a JSON object with all the packages
"""
route("/api/v1/packages", PkgVizBoard.StatsController.API.V1.packages, method = GET)
swagger"""
/api/v1/stats:
get:
summary: Query the download stats
description: Query the download stats
parameters:
- in: query
name: packages
description: A list of package names
schema:
type: array
items:
type: string
example: ['Genie', 'Stipple']
- in: query
name: regions
description: A list of regions
schema:
type: array
items:
type: string
example: ['eu-central', 'us-west']
- in: query
name: startdate
schema:
type: string
format: date
example: '2021-12-30'
description: The start date
- in: query
name: enddate
schema:
type: string
format: date
example: '2022-01-15'
description: The end date
responses:
'200':
description: Returns a JSON object with all the download stats
post:
summary: Query the download stats
description: Query the download stats
parameters:
- in: query
name: packages
description: A list of package names
schema:
type: array
items:
type: string
example: ['Genie', 'Stipple']
- in: query
name: regions
description: A list of regions
schema:
type: array
items:
type: string
example: ['eu-central', 'us-west']
- in: query
name: startdate
schema:
type: string
format: date
example: '2021-12-30'
description: The start date
- in: query
name: enddate
schema:
type: string
format: date
example: '2022-01-15'
description: The end date
responses:
'201':
description: Returns a JSON object with all the download stats
"""
[route("/api/v1/stats", PkgVizBoard.StatsController.API.V1.search, method = m) for m in [GET, POST]]
swagger"""
/api/v1/badge/{packages}:
get:
summary: Get badge
description: Get badge
parameters:
- in: path
name: packages
required: true
schema:
type: string
example: 'Genie'
responses:
'200':
description: Returns a badge
"""
route("/api/v1/badge/:packages", PkgVizBoard.StatsController.API.V1.badge, method = GET)
swagger"""
/api/v1/badge/{packages}/{options}:
get:
summary: Get badge
description: Get badge
parameters:
- in: path
name: packages
required: true
schema:
type: string
example: 'Genie'
- in: path
name: options
required: true
schema:
type: string
responses:
'200':
description: Returns a badge
"""
route("/api/v1/badge/:packages/:options", PkgVizBoard.StatsController.API.V1.badge, method = GET, named = :get_api_v1_badge_packages_options)
route("/docs") do
render_swagger(
build(
OpenAPI("3.0",
Dict( "title" => "PkgVizBoard API",
"version" => "1.0.5")
)
),
options = Options(
custom_favicon = "/favicon.ico",
custom_site_title = "Package download stats for Julia - Swagger",
show_explorer = false
)
)
end