From 4e8e83db1a20c76a81967af4e7e3a8634649790a Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 17 Aug 2024 01:01:33 +0200 Subject: [PATCH] feat: Move /latest routes to parent There is only ever current releases, so a latest route doesn't make sense. --- .../api/configuration/routes/ManagerRoute.kt | 34 ++++++------ .../api/configuration/routes/PatchesRoute.kt | 54 +++++++++---------- 2 files changed, 42 insertions(+), 46 deletions(-) diff --git a/src/main/kotlin/app/revanced/api/configuration/routes/ManagerRoute.kt b/src/main/kotlin/app/revanced/api/configuration/routes/ManagerRoute.kt index b87024cf..78b4c65b 100644 --- a/src/main/kotlin/app/revanced/api/configuration/routes/ManagerRoute.kt +++ b/src/main/kotlin/app/revanced/api/configuration/routes/ManagerRoute.kt @@ -16,31 +16,29 @@ import org.koin.ktor.ext.get as koinGet internal fun Route.managerRoute() = route("manager") { val managerService = koinGet() - route("latest") { - installLatestManagerRouteDocumentation() + installManagerRouteDocumentation() - rateLimit(RateLimitName("weak")) { - get { - call.respond(managerService.latestRelease()) - } + rateLimit(RateLimitName("weak")) { + get { + call.respond(managerService.latestRelease()) + } - route("version") { - installLatestManagerVersionRouteDocumentation() + route("version") { + installManagerVersionRouteDocumentation() - get { - call.respond(managerService.latestVersion()) - } + get { + call.respond(managerService.latestVersion()) } } } } -private fun Route.installLatestManagerRouteDocumentation() = installNotarizedRoute { +private fun Route.installManagerRouteDocumentation() = installNotarizedRoute { tags = setOf("Manager") get = GetInfo.builder { - description("Get the latest manager release") - summary("Get latest manager release") + description("Get the current manager release") + summary("Get current manager release") response { description("The latest manager release") mediaTypes("application/json") @@ -50,14 +48,14 @@ private fun Route.installLatestManagerRouteDocumentation() = installNotarizedRou } } -private fun Route.installLatestManagerVersionRouteDocumentation() = installNotarizedRoute { +private fun Route.installManagerVersionRouteDocumentation() = installNotarizedRoute { tags = setOf("Manager") get = GetInfo.builder { - description("Get the latest manager release version") - summary("Get latest manager release version") + description("Get the current manager release version") + summary("Get current manager release version") response { - description("The latest manager release version") + description("The current manager release version") mediaTypes("application/json") responseCode(HttpStatusCode.OK) responseType() diff --git a/src/main/kotlin/app/revanced/api/configuration/routes/PatchesRoute.kt b/src/main/kotlin/app/revanced/api/configuration/routes/PatchesRoute.kt index b1ff8412..11759cd2 100644 --- a/src/main/kotlin/app/revanced/api/configuration/routes/PatchesRoute.kt +++ b/src/main/kotlin/app/revanced/api/configuration/routes/PatchesRoute.kt @@ -19,30 +19,28 @@ import org.koin.ktor.ext.get as koinGet internal fun Route.patchesRoute() = route("patches") { val patchesService = koinGet() - route("latest") { - installLatestPatchesRouteDocumentation() + installPatchesRouteDocumentation() - rateLimit(RateLimitName("weak")) { - get { - call.respond(patchesService.latestRelease()) - } + rateLimit(RateLimitName("weak")) { + get { + call.respond(patchesService.latestRelease()) + } - route("version") { - installLatestPatchesVersionRouteDocumentation() + route("version") { + installPatchesVersionRouteDocumentation() - get { - call.respond(patchesService.latestVersion()) - } + get { + call.respond(patchesService.latestVersion()) } } + } - rateLimit(RateLimitName("strong")) { - route("list") { - installLatestPatchesListRouteDocumentation() + rateLimit(RateLimitName("strong")) { + route("list") { + installPatchesListRouteDocumentation() - get { - call.respondBytes(ContentType.Application.Json) { patchesService.list() } - } + get { + call.respondBytes(ContentType.Application.Json) { patchesService.list() } } } } @@ -60,14 +58,14 @@ internal fun Route.patchesRoute() = route("patches") { } } -private fun Route.installLatestPatchesRouteDocumentation() = installNotarizedRoute { +private fun Route.installPatchesRouteDocumentation() = installNotarizedRoute { tags = setOf("Patches") get = GetInfo.builder { - description("Get the latest patches release") - summary("Get latest patches release") + description("Get the current patches release") + summary("Get current patches release") response { - description("The latest patches release") + description("The current patches release") mediaTypes("application/json") responseCode(HttpStatusCode.OK) responseType>() @@ -75,14 +73,14 @@ private fun Route.installLatestPatchesRouteDocumentation() = installNotarizedRou } } -private fun Route.installLatestPatchesVersionRouteDocumentation() = installNotarizedRoute { +private fun Route.installPatchesVersionRouteDocumentation() = installNotarizedRoute { tags = setOf("Patches") get = GetInfo.builder { - description("Get the latest patches release version") - summary("Get latest patches release version") + description("Get the current patches release version") + summary("Get current patches release version") response { - description("The latest patches release version") + description("The current patches release version") mediaTypes("application/json") responseCode(HttpStatusCode.OK) responseType() @@ -90,12 +88,12 @@ private fun Route.installLatestPatchesVersionRouteDocumentation() = installNotar } } -private fun Route.installLatestPatchesListRouteDocumentation() = installNotarizedRoute { +private fun Route.installPatchesListRouteDocumentation() = installNotarizedRoute { tags = setOf("Patches") get = GetInfo.builder { - description("Get the list of patches from the latest patches release") - summary("Get list of patches from latest patches release") + description("Get the list of patches from the current patches release") + summary("Get list of patches from current patches release") response { description("The list of patches") mediaTypes("application/json")