Skip to content

Commit

Permalink
fix: Move old API endpoint configuration from env to configuration file
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Jul 11, 2024
1 parent 8f77736 commit 7e99e49
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 18 deletions.
2 changes: 0 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Optional token for API calls to the backend
BACKEND_API_TOKEN=
# A URL to the old API to proxy for migration purposes
OLD_API_URL=

# Database connection details
DB_URL=jdbc:h2:./persistence/revanced-api
Expand Down
1 change: 1 addition & 0 deletions configuration.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ cors-allowed-hosts = [
"*.revanced.app"
]
endpoint = "https://api.revanced.app"
old-api-endpoint = "https://old-api.revanced.app"
14 changes: 0 additions & 14 deletions configuration.toml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,11 @@ fun Application.configureDependencies(
AuthService(issuer, validityInMin, jwtSecret, authSHA256DigestString)
}
single {
val configuration = get<ConfigurationRepository>()

OldApiService(
get {
val defaultRequestUri = get<Dotenv>()["OLD_API_URL"]
parameterArrayOf(defaultRequestUri)
parameterArrayOf(configuration.oldApiEndpoint)
},
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import java.io.File
* @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.
*/
@Serializable
internal class ConfigurationRepository(
Expand All @@ -34,6 +35,8 @@ internal class ConfigurationRepository(
@SerialName("cors-allowed-hosts")
val corsAllowedHosts: Set<String>,
val endpoint: String,
@SerialName("old-api-endpoint")
val oldApiEndpoint: String,
) {
/**
* An asset configuration.
Expand Down

0 comments on commit 7e99e49

Please sign in to comment.