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 78b4c65b..811f3a93 100644 --- a/src/main/kotlin/app/revanced/api/configuration/routes/ManagerRoute.kt +++ b/src/main/kotlin/app/revanced/api/configuration/routes/ManagerRoute.kt @@ -14,9 +14,18 @@ import io.ktor.server.routing.* import org.koin.ktor.ext.get as koinGet internal fun Route.managerRoute() = route("manager") { + configure() + + // TODO: Remove this deprecated route eventually. + route("latest") { + configure(deprecated = true) + } +} + +private fun Route.configure(deprecated: Boolean = false) { val managerService = koinGet() - installManagerRouteDocumentation() + installManagerRouteDocumentation(deprecated) rateLimit(RateLimitName("weak")) { get { @@ -24,7 +33,7 @@ internal fun Route.managerRoute() = route("manager") { } route("version") { - installManagerVersionRouteDocumentation() + installManagerVersionRouteDocumentation(deprecated) get { call.respond(managerService.latestVersion()) @@ -33,10 +42,11 @@ internal fun Route.managerRoute() = route("manager") { } } -private fun Route.installManagerRouteDocumentation() = installNotarizedRoute { +private fun Route.installManagerRouteDocumentation(deprecated: Boolean) = installNotarizedRoute { tags = setOf("Manager") get = GetInfo.builder { + if (deprecated) isDeprecated() description("Get the current manager release") summary("Get current manager release") response { @@ -48,10 +58,11 @@ private fun Route.installManagerRouteDocumentation() = installNotarizedRoute { } } -private fun Route.installManagerVersionRouteDocumentation() = installNotarizedRoute { +private fun Route.installManagerVersionRouteDocumentation(deprecated: Boolean) = installNotarizedRoute { tags = setOf("Manager") get = GetInfo.builder { + if (deprecated) isDeprecated() description("Get the current manager release version") summary("Get current manager release version") response { 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 11759cd2..efe7e100 100644 --- a/src/main/kotlin/app/revanced/api/configuration/routes/PatchesRoute.kt +++ b/src/main/kotlin/app/revanced/api/configuration/routes/PatchesRoute.kt @@ -17,9 +17,18 @@ import kotlin.time.Duration.Companion.days import org.koin.ktor.ext.get as koinGet internal fun Route.patchesRoute() = route("patches") { + configure() + + // TODO: Remove this deprecated route eventually. + route("latest") { + configure(deprecated = true) + } +} + +private fun Route.configure(deprecated: Boolean = false) { val patchesService = koinGet() - installPatchesRouteDocumentation() + installPatchesRouteDocumentation(deprecated) rateLimit(RateLimitName("weak")) { get { @@ -27,7 +36,7 @@ internal fun Route.patchesRoute() = route("patches") { } route("version") { - installPatchesVersionRouteDocumentation() + installPatchesVersionRouteDocumentation(deprecated) get { call.respond(patchesService.latestVersion()) @@ -37,7 +46,7 @@ internal fun Route.patchesRoute() = route("patches") { rateLimit(RateLimitName("strong")) { route("list") { - installPatchesListRouteDocumentation() + installPatchesListRouteDocumentation(deprecated) get { call.respondBytes(ContentType.Application.Json) { patchesService.list() } @@ -49,7 +58,7 @@ internal fun Route.patchesRoute() = route("patches") { route("keys") { installCache(356.days) - installPatchesPublicKeyRouteDocumentation() + installPatchesPublicKeyRouteDocumentation(deprecated) get { call.respond(patchesService.publicKeys()) @@ -58,10 +67,11 @@ internal fun Route.patchesRoute() = route("patches") { } } -private fun Route.installPatchesRouteDocumentation() = installNotarizedRoute { +private fun Route.installPatchesRouteDocumentation(deprecated: Boolean) = installNotarizedRoute { tags = setOf("Patches") get = GetInfo.builder { + if (deprecated) isDeprecated() description("Get the current patches release") summary("Get current patches release") response { @@ -73,10 +83,11 @@ private fun Route.installPatchesRouteDocumentation() = installNotarizedRoute { } } -private fun Route.installPatchesVersionRouteDocumentation() = installNotarizedRoute { +private fun Route.installPatchesVersionRouteDocumentation(deprecated: Boolean) = installNotarizedRoute { tags = setOf("Patches") get = GetInfo.builder { + if (deprecated) isDeprecated() description("Get the current patches release version") summary("Get current patches release version") response { @@ -88,10 +99,11 @@ private fun Route.installPatchesVersionRouteDocumentation() = installNotarizedRo } } -private fun Route.installPatchesListRouteDocumentation() = installNotarizedRoute { +private fun Route.installPatchesListRouteDocumentation(deprecated: Boolean) = installNotarizedRoute { tags = setOf("Patches") get = GetInfo.builder { + if (deprecated) isDeprecated() description("Get the list of patches from the current patches release") summary("Get list of patches from current patches release") response { @@ -103,10 +115,11 @@ private fun Route.installPatchesListRouteDocumentation() = installNotarizedRoute } } -private fun Route.installPatchesPublicKeyRouteDocumentation() = installNotarizedRoute { +private fun Route.installPatchesPublicKeyRouteDocumentation(deprecated: Boolean) = installNotarizedRoute { tags = setOf("Patches") get = GetInfo.builder { + if (deprecated) isDeprecated() description("Get the public keys for verifying patches and integrations assets") summary("Get patches and integrations public keys") response {