fix: Move old API endpoint configuration from env to configuration file

This commit is contained in:
oSumAtrIX 2024-07-11 04:26:26 +02:00
parent 8f77736a69
commit 7e99e49af2
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4
5 changed files with 7 additions and 18 deletions

View File

@ -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

View File

@ -15,3 +15,4 @@ cors-allowed-hosts = [
"*.revanced.app"
]
endpoint = "https://api.revanced.app"
old-api-endpoint = "https://old-api.revanced.app"

View File

@ -1,14 +0,0 @@
organization = "revanced"
patches = { repository = "revanced-patches", asset-regex = "jar$", signature-asset-regex = "asc$", public-key-file = "key.asc" }
integrations = { repository = "revanced-integrations", asset-regex = "apk$", signature-asset-regex = "asc$", public-key-file = "key.asc" }
contributors-repositories = [
"revanced-patcher",
"revanced-patches",
"revanced-integrations",
"revanced-website",
"revanced-cli",
"revanced-manager",
]
api-version = 1
cors = { host = "*.127.0.0.1:8888", sub-domains = [] }
endpoint = "http://127.0.0.1:8888/"

View File

@ -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)
},
)
}

View File

@ -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(
@ -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.