Skip to content

Commit

Permalink
feat: Remove deprecated routes and old API
Browse files Browse the repository at this point in the history
Backwards compatibility should be and is now handled by the reverse proxy.
  • Loading branch information
oSumAtrIX committed Nov 6, 2024
1 parent 0b66fc2 commit eca40a6
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 141 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ Some of the features ReVanced API include:
and links of the hoster of ReVanced API
- 🧩 **Patches**: Get the latest updates of ReVanced Patches, directly from ReVanced API
- 👥 **Contributors**: List all contributors involved in the project
- 🔄 **Backwards compatibility**: Proxy an old API for migration purposes and backwards compatibility

## 🚀 How to get started

Expand Down
1 change: 0 additions & 1 deletion configuration.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ cors-allowed-hosts = [
"*.revanced.app"
]
endpoint = "https://api.revanced.app"
old-api-endpoint = "https://old-api.revanced.app"
static-files-path = "static/root"
versioned-static-files-path = "static/versioned"
backend-service-name = "GitHub"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ fun Application.configureDependencies(

AuthenticationService(issuer, validityInMin, jwtSecret, authSHA256DigestString)
}
singleOf(::OldApiService)
singleOf(::AnnouncementService)
singleOf(::SignatureService)
singleOf(::PatchesService)
Expand Down
4 changes: 0 additions & 4 deletions src/main/kotlin/app/revanced/api/configuration/Routing.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import app.revanced.api.configuration.repository.ConfigurationRepository
import app.revanced.api.configuration.routes.*
import app.revanced.api.configuration.routes.announcementsRoute
import app.revanced.api.configuration.routes.apiRoute
import app.revanced.api.configuration.routes.oldApiRoute
import app.revanced.api.configuration.routes.patchesRoute
import io.bkbn.kompendium.core.routes.redoc
import io.bkbn.kompendium.core.routes.swagger
Expand Down Expand Up @@ -55,7 +54,4 @@ internal fun Application.configureRouting() = routing {

swagger(pageTitle = "ReVanced API", path = "/")
redoc(pageTitle = "ReVanced API", path = "/redoc")

// TODO: Remove, once migration period from v2 API is over (In 1-2 years).
oldApiRoute()
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import kotlin.io.path.createDirectories
* @property apiVersion The version to use for the API.
* @property corsAllowedHosts The hosts allowed to make requests to the API.
* @property endpoint The endpoint of the API.
* @property oldApiEndpoint The endpoint of the old API to proxy requests to.
* @property staticFilesPath The path to the static files to be served under the root path.
* @property versionedStaticFilesPath The path to the static files to be served under a versioned path.
* @property about The path to the json file deserialized to [APIAbout]
Expand All @@ -50,8 +49,6 @@ internal class ConfigurationRepository(
@SerialName("cors-allowed-hosts")
val corsAllowedHosts: Set<String>,
val endpoint: String,
@SerialName("old-api-endpoint")
val oldApiEndpoint: String,
@Serializable(with = PathSerializer::class)
@SerialName("static-files-path")
val staticFilesPath: Path,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,17 @@ 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<ManagerService>()

installManagerRouteDocumentation(deprecated)
installManagerRouteDocumentation()

rateLimit(RateLimitName("weak")) {
get {
call.respond(managerService.latestRelease())
}

route("version") {
installManagerVersionRouteDocumentation(deprecated)
installManagerVersionRouteDocumentation()

get {
call.respond(managerService.latestVersion())
Expand All @@ -41,11 +32,10 @@ private fun Route.configure(deprecated: Boolean = false) {
}
}

private fun Route.installManagerRouteDocumentation(deprecated: Boolean) = installNotarizedRoute {
private fun Route.installManagerRouteDocumentation() = installNotarizedRoute {
tags = setOf("Manager")

get = GetInfo.builder {
if (deprecated) isDeprecated()
description("Get the current manager release")
summary("Get current manager release")
response {
Expand All @@ -57,11 +47,10 @@ private fun Route.installManagerRouteDocumentation(deprecated: Boolean) = instal
}
}

private fun Route.installManagerVersionRouteDocumentation(deprecated: Boolean) = installNotarizedRoute {
private fun Route.installManagerVersionRouteDocumentation() = installNotarizedRoute {
tags = setOf("Manager")

get = GetInfo.builder {
if (deprecated) isDeprecated()
description("Get the current manager release version")
summary("Get current manager release version")
response {
Expand Down
19 changes: 0 additions & 19 deletions src/main/kotlin/app/revanced/api/configuration/routes/OldApi.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,17 @@ 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<PatchesService>()

installPatchesRouteDocumentation(deprecated)
installPatchesRouteDocumentation()

rateLimit(RateLimitName("weak")) {
get {
call.respond(patchesService.latestRelease())
}

route("version") {
installPatchesVersionRouteDocumentation(deprecated)
installPatchesVersionRouteDocumentation()

get {
call.respond(patchesService.latestVersion())
Expand All @@ -45,7 +36,7 @@ private fun Route.configure(deprecated: Boolean = false) {

rateLimit(RateLimitName("strong")) {
route("list") {
installPatchesListRouteDocumentation(deprecated)
installPatchesListRouteDocumentation()

get {
call.respondBytes(ContentType.Application.Json) { patchesService.list() }
Expand All @@ -57,7 +48,7 @@ private fun Route.configure(deprecated: Boolean = false) {
route("keys") {
installCache(356.days)

installPatchesPublicKeyRouteDocumentation(deprecated)
installPatchesPublicKeyRouteDocumentation()

get {
call.respond(patchesService.publicKey())
Expand All @@ -66,11 +57,10 @@ private fun Route.configure(deprecated: Boolean = false) {
}
}

private fun Route.installPatchesRouteDocumentation(deprecated: Boolean) = installNotarizedRoute {
private fun Route.installPatchesRouteDocumentation() = installNotarizedRoute {
tags = setOf("Patches")

get = GetInfo.builder {
if (deprecated) isDeprecated()
description("Get the current patches release")
summary("Get current patches release")
response {
Expand All @@ -82,11 +72,10 @@ private fun Route.installPatchesRouteDocumentation(deprecated: Boolean) = instal
}
}

private fun Route.installPatchesVersionRouteDocumentation(deprecated: Boolean) = installNotarizedRoute {
private fun Route.installPatchesVersionRouteDocumentation() = installNotarizedRoute {
tags = setOf("Patches")

get = GetInfo.builder {
if (deprecated) isDeprecated()
description("Get the current patches release version")
summary("Get current patches release version")
response {
Expand All @@ -98,11 +87,10 @@ private fun Route.installPatchesVersionRouteDocumentation(deprecated: Boolean) =
}
}

private fun Route.installPatchesListRouteDocumentation(deprecated: Boolean) = installNotarizedRoute {
private fun Route.installPatchesListRouteDocumentation() = 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 {
Expand All @@ -114,11 +102,10 @@ private fun Route.installPatchesListRouteDocumentation(deprecated: Boolean) = in
}
}

private fun Route.installPatchesPublicKeyRouteDocumentation(deprecated: Boolean) = installNotarizedRoute {
private fun Route.installPatchesPublicKeyRouteDocumentation() = installNotarizedRoute {
tags = setOf("Patches")

get = GetInfo.builder {
if (deprecated) isDeprecated()
description("Get the public keys for verifying patches assets")
summary("Get patches public keys")
response {
Expand Down

This file was deleted.

0 comments on commit eca40a6

Please sign in to comment.