Compare commits

..

4 Commits

Author SHA1 Message Date
semantic-release-bot
e92fbdf1f4 chore(release): 1.0.0-dev.3 [skip ci]
# [1.0.0-dev.3](https://github.com/ReVanced/revanced-api/compare/v1.0.0-dev.2...v1.0.0-dev.3) (2024-07-11)

### Bug Fixes

* Move old API endpoint configuration from env to configuration file ([7e99e49](7e99e49af2))
2024-07-11 02:28:50 +00:00
oSumAtrIX
7e99e49af2 fix: Move old API endpoint configuration from env to configuration file 2024-07-11 04:27:02 +02:00
semantic-release-bot
8f77736a69 chore(release): 1.0.0-dev.2 [skip ci]
# [1.0.0-dev.2](https://github.com/ReVanced/revanced-api/compare/v1.0.0-dev.1...v1.0.0-dev.2) (2024-07-11)

### Bug Fixes

* Configure CORS correctly ([2ed4cf3](2ed4cf3b40))
2024-07-11 01:52:59 +00:00
oSumAtrIX
2ed4cf3b40 fix: Configure CORS correctly 2024-07-11 03:50:48 +02:00
8 changed files with 36 additions and 40 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

@@ -1,3 +1,17 @@
# [1.0.0-dev.3](https://github.com/ReVanced/revanced-api/compare/v1.0.0-dev.2...v1.0.0-dev.3) (2024-07-11)
### Bug Fixes
* Move old API endpoint configuration from env to configuration file ([7e99e49](https://github.com/ReVanced/revanced-api/commit/7e99e49af202c4ec0a0d7e61dd0182dd2097e867))
# [1.0.0-dev.2](https://github.com/ReVanced/revanced-api/compare/v1.0.0-dev.1...v1.0.0-dev.2) (2024-07-11)
### Bug Fixes
* Configure CORS correctly ([2ed4cf3](https://github.com/ReVanced/revanced-api/commit/2ed4cf3b40caeb6181d068d411344e6732000f22))
# 1.0.0-dev.1 (2024-07-10)

View File

@@ -10,5 +10,9 @@ contributors-repositories = [
"revanced-manager",
]
api-version = 1
cors = { host = "*.revanced.app", sub-domains = [] }
endpoint = "https://api.revanced.app"
cors-allowed-hosts = [
"revanced.app",
"*.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

@@ -1,4 +1,4 @@
org.gradle.parallel = true
org.gradle.caching = true
kotlin.code.style = official
version = 1.0.0-dev.1
version = 1.0.0-dev.3

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

@@ -13,10 +13,12 @@ fun Application.configureHTTP() {
val configurationRepository = get<ConfigurationRepository>()
install(CORS) {
allowHost(
host = configurationRepository.cors.host,
subDomains = configurationRepository.cors.subDomains,
)
configurationRepository.corsAllowedHosts.forEach { host ->
allowHost(
host = host,
schemes = listOf("http", "https")
)
}
}
install(RateLimit) {

View File

@@ -19,8 +19,9 @@ import java.io.File
* @property integrations The source of the integrations.
* @property contributorsRepositoryNames The names of the repositories to get contributors from.
* @property apiVersion The version to use for the API.
* @property cors The CORS configuration.
* @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(
@@ -31,8 +32,11 @@ internal class ConfigurationRepository(
val contributorsRepositoryNames: Set<String>,
@SerialName("api-version")
val apiVersion: Int = 1,
val cors: Cors,
@SerialName("cors-allowed-hosts")
val corsAllowedHosts: Set<String>,
val endpoint: String,
@SerialName("old-api-endpoint")
val oldApiEndpoint: String,
) {
/**
* An asset configuration.
@@ -61,19 +65,6 @@ internal class ConfigurationRepository(
@SerialName("public-key-file")
val publicKeyFile: File,
)
/**
* The CORS configuration.
*
* @property host The host of the API to configure CORS.
* @property subDomains The subdomains to allow for CORS.
*/
@Serializable
internal class Cors(
val host: String,
@SerialName("sub-domains")
val subDomains: List<String>,
)
}
private object RegexSerializer : KSerializer<Regex> {