mirror of
https://github.com/revanced/revanced-api.git
synced 2025-04-29 14:14:29 +02:00
feat: Add URL and use friendly name for APIContributable
This commit is contained in:
parent
f91f3a65c5
commit
a5498aba2b
@ -2,14 +2,6 @@ organization = "revanced"
|
||||
patches = { repository = "revanced-patches", asset-regex = "jar$", signature-asset-regex = "asc$", public-key-file = "patches-public-key.asc", public-key-id = 0 }
|
||||
integrations = { repository = "revanced-integrations", asset-regex = "apk$", signature-asset-regex = "asc$", public-key-file = "integrations-public-key.asc", public-key-id = 0 }
|
||||
manager = { repository = "revanced-manager", asset-regex = "apk$" }
|
||||
contributors-repositories = [
|
||||
"revanced-patcher",
|
||||
"revanced-patches",
|
||||
"revanced-integrations",
|
||||
"revanced-website",
|
||||
"revanced-cli",
|
||||
"revanced-manager",
|
||||
]
|
||||
api-version = 1
|
||||
cors-allowed-hosts = [
|
||||
"revanced.app",
|
||||
@ -21,3 +13,9 @@ static-files-path = "static/root"
|
||||
versioned-static-files-path = "static/versioned"
|
||||
about-json-file-path = "about.json"
|
||||
backend-service-name = "GitHub"
|
||||
[contributors-repositories]
|
||||
revanced-patcher = "ReVanced Patcher"
|
||||
revanced-patches = "ReVanced Patches"
|
||||
revanced-website = "ReVanced Website"
|
||||
revanced-cli = "ReVanced CLI"
|
||||
revanced-manager = "ReVanced Manager"
|
@ -26,7 +26,7 @@ import kotlin.io.path.createDirectories
|
||||
* @property patches The source of the patches.
|
||||
* @property integrations The source of the integrations.
|
||||
* @property manager The source of the manager.
|
||||
* @property contributorsRepositoryNames The names of the repositories to get contributors from.
|
||||
* @property contributorsRepositoryNames The friendly name of repos mapped to the repository names to get contributors from.
|
||||
* @property backendServiceName The name of the backend service to use for the repositories, contributors, etc.
|
||||
* @property apiVersion The version to use for the API.
|
||||
* @property corsAllowedHosts The hosts allowed to make requests to the API.
|
||||
@ -44,7 +44,7 @@ internal class ConfigurationRepository(
|
||||
val integrations: SignedAssetConfiguration,
|
||||
val manager: AssetConfiguration,
|
||||
@SerialName("contributors-repositories")
|
||||
val contributorsRepositoryNames: Set<String>,
|
||||
val contributorsRepositoryNames: Map<String, String>,
|
||||
@SerialName("backend-service-name")
|
||||
val backendServiceName: String,
|
||||
@SerialName("api-version")
|
||||
|
@ -35,6 +35,7 @@ class ApiContributor(
|
||||
@Serializable
|
||||
class APIContributable(
|
||||
val name: String,
|
||||
val url: String,
|
||||
// Using a list instead of a set because set semantics are unnecessary here.
|
||||
val contributors: List<ApiContributor>,
|
||||
)
|
||||
|
@ -3,6 +3,7 @@ package app.revanced.api.configuration.services
|
||||
import app.revanced.api.configuration.repository.BackendRepository
|
||||
import app.revanced.api.configuration.repository.ConfigurationRepository
|
||||
import app.revanced.api.configuration.schema.*
|
||||
import io.ktor.http.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
@ -16,11 +17,15 @@ internal class ApiService(
|
||||
val about = configurationRepository.about
|
||||
|
||||
suspend fun contributors() = withContext(Dispatchers.IO) {
|
||||
configurationRepository.contributorsRepositoryNames.map {
|
||||
configurationRepository.contributorsRepositoryNames.map { (repository, name) ->
|
||||
async {
|
||||
APIContributable(
|
||||
it,
|
||||
backendRepository.contributors(configurationRepository.organization, it).map {
|
||||
name,
|
||||
URLBuilder().apply {
|
||||
takeFrom(backendRepository.website)
|
||||
path(configurationRepository.organization, repository)
|
||||
}.buildString(),
|
||||
backendRepository.contributors(configurationRepository.organization, repository).map {
|
||||
ApiContributor(it.name, it.avatarUrl, it.url, it.contributions)
|
||||
},
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user