@@ -7,6 +7,8 @@ import app.revanced.api.configuration.installCache
7
7
import app.revanced.api.configuration.installNotarizedRoute
8
8
import app.revanced.api.configuration.services.PatchesService
9
9
import io.bkbn.kompendium.core.metadata.GetInfo
10
+ import io.bkbn.kompendium.json.schema.definition.TypeDefinition
11
+ import io.bkbn.kompendium.oas.payload.Parameter
10
12
import io.ktor.http.*
11
13
import io.ktor.server.application.*
12
14
import io.ktor.server.plugins.ratelimit.*
@@ -22,14 +24,18 @@ internal fun Route.patchesRoute() = route("patches") {
22
24
23
25
rateLimit(RateLimitName (" weak" )) {
24
26
get {
25
- call.respond(patchesService.latestRelease())
27
+ val prerelease = call.parameters[" prerelease" ]?.toBoolean() ? : false
28
+
29
+ call.respond(patchesService.latestRelease(prerelease))
26
30
}
27
31
28
32
route(" version" ) {
29
33
installPatchesVersionRouteDocumentation()
30
34
31
35
get {
32
- call.respond(patchesService.latestVersion())
36
+ val prerelease = call.parameters[" prerelease" ]?.toBoolean() ? : false
37
+
38
+ call.respond(patchesService.latestVersion(prerelease))
33
39
}
34
40
}
35
41
}
@@ -39,7 +45,9 @@ internal fun Route.patchesRoute() = route("patches") {
39
45
installPatchesListRouteDocumentation()
40
46
41
47
get {
42
- call.respondBytes(ContentType .Application .Json ) { patchesService.list() }
48
+ val prerelease = call.parameters[" prerelease" ]?.toBoolean() ? : false
49
+
50
+ call.respondBytes(ContentType .Application .Json ) { patchesService.list(prerelease) }
43
51
}
44
52
}
45
53
}
@@ -57,12 +65,21 @@ internal fun Route.patchesRoute() = route("patches") {
57
65
}
58
66
}
59
67
68
+ private val prereleaseParameter = Parameter (
69
+ name = " prerelease" ,
70
+ `in ` = Parameter .Location .query,
71
+ schema = TypeDefinition .STRING ,
72
+ description = " Whether to get the current patches prerelease" ,
73
+ required = false ,
74
+ )
75
+
60
76
private fun Route.installPatchesRouteDocumentation () = installNotarizedRoute {
61
77
tags = setOf (" Patches" )
62
78
63
79
get = GetInfo .builder {
64
80
description(" Get the current patches release" )
65
81
summary(" Get current patches release" )
82
+ parameters(prereleaseParameter)
66
83
response {
67
84
description(" The current patches release" )
68
85
mediaTypes(" application/json" )
@@ -78,6 +95,7 @@ private fun Route.installPatchesVersionRouteDocumentation() = installNotarizedRo
78
95
get = GetInfo .builder {
79
96
description(" Get the current patches release version" )
80
97
summary(" Get current patches release version" )
98
+ parameters(prereleaseParameter)
81
99
response {
82
100
description(" The current patches release version" )
83
101
mediaTypes(" application/json" )
@@ -93,6 +111,7 @@ private fun Route.installPatchesListRouteDocumentation() = installNotarizedRoute
93
111
get = GetInfo .builder {
94
112
description(" Get the list of patches from the current patches release" )
95
113
summary(" Get list of patches from current patches release" )
114
+ parameters(prereleaseParameter)
96
115
response {
97
116
description(" The list of patches" )
98
117
mediaTypes(" application/json" )
0 commit comments