From e871b23210798723c34bce93c7567d8fbcf4e060 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Wed, 6 Nov 2024 05:30:00 +0100 Subject: [PATCH 1/6] feat: Move spec url to versioned path --- .../app/revanced/api/configuration/HTTP.kt | 4 ++-- .../app/revanced/api/configuration/OpenAPI.kt | 16 +++++++++++++--- .../app/revanced/api/configuration/Routing.kt | 5 +++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/app/revanced/api/configuration/HTTP.kt b/src/main/kotlin/app/revanced/api/configuration/HTTP.kt index 523ea8e7..27b3bbfe 100644 --- a/src/main/kotlin/app/revanced/api/configuration/HTTP.kt +++ b/src/main/kotlin/app/revanced/api/configuration/HTTP.kt @@ -11,7 +11,7 @@ import org.koin.ktor.ext.get import kotlin.time.Duration.Companion.minutes fun Application.configureHTTP() { - val configurationRepository = get() + val configuration = get() install(CORS) { HttpMethod.DefaultMethods.minus(HttpMethod.Options).forEach(::allowMethod) @@ -22,7 +22,7 @@ fun Application.configureHTTP() { allowCredentials = true - configurationRepository.corsAllowedHosts.forEach { host -> + configuration.corsAllowedHosts.forEach { host -> allowHost(host = host, schemes = listOf("https")) } } diff --git a/src/main/kotlin/app/revanced/api/configuration/OpenAPI.kt b/src/main/kotlin/app/revanced/api/configuration/OpenAPI.kt index 3c903215..7aacc496 100644 --- a/src/main/kotlin/app/revanced/api/configuration/OpenAPI.kt +++ b/src/main/kotlin/app/revanced/api/configuration/OpenAPI.kt @@ -2,6 +2,7 @@ package app.revanced.api.configuration import app.revanced.api.command.applicationVersion import app.revanced.api.configuration.repository.ConfigurationRepository +import io.bkbn.kompendium.core.attribute.KompendiumAttributes import io.bkbn.kompendium.core.plugin.NotarizedApplication import io.bkbn.kompendium.json.schema.KotlinXSchemaConfigurator import io.bkbn.kompendium.oas.OpenApiSpec @@ -12,13 +13,22 @@ import io.bkbn.kompendium.oas.info.License import io.bkbn.kompendium.oas.security.BearerAuth import io.bkbn.kompendium.oas.server.Server import io.ktor.server.application.* -import org.koin.ktor.ext.get +import io.ktor.server.response.* +import io.ktor.server.routing.* import java.net.URI +import org.koin.ktor.ext.get as koinGet internal fun Application.configureOpenAPI() { - val configurationRepository = get() + val configuration = koinGet() install(NotarizedApplication()) { + openApiJson = { + route("/${configuration.apiVersion}/openapi.json") { + get { + call.respond(application.attributes[KompendiumAttributes.openApiSpec]) + } + } + } spec = OpenApiSpec( info = Info( title = "ReVanced API", @@ -41,7 +51,7 @@ internal fun Application.configureOpenAPI() { ), ).apply { servers += Server( - url = URI(configurationRepository.endpoint), + url = URI(configuration.endpoint), description = "ReVanced API server", ) } diff --git a/src/main/kotlin/app/revanced/api/configuration/Routing.kt b/src/main/kotlin/app/revanced/api/configuration/Routing.kt index da1af7c7..0b615296 100644 --- a/src/main/kotlin/app/revanced/api/configuration/Routing.kt +++ b/src/main/kotlin/app/revanced/api/configuration/Routing.kt @@ -52,6 +52,7 @@ internal fun Application.configureRouting() = routing { extensions("json", "asc") } - swagger(pageTitle = "ReVanced API", path = "/") - redoc(pageTitle = "ReVanced API", path = "/redoc") + val specUrl = "/${configuration.apiVersion}/openapi.json" + swagger(pageTitle = "ReVanced API", path = "/", specUrl = specUrl) + redoc(pageTitle = "ReVanced API", path = "/redoc", specUrl = specUrl) } From 6c8153ba987e1b883492261004a3faabe04b6c86 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 6 Nov 2024 04:32:10 +0000 Subject: [PATCH 2/6] chore: Release v1.5.0-dev.1 [skip ci] # [1.5.0-dev.1](https://github.com/ReVanced/revanced-api/compare/v1.4.0...v1.5.0-dev.1) (2024-11-06) ### Features * Move spec url to versioned path ([e871b23](https://github.com/ReVanced/revanced-api/commit/e871b23210798723c34bce93c7567d8fbcf4e060)) --- CHANGELOG.md | 7 +++++++ gradle.properties | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79aec4e5..a56d787a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [1.5.0-dev.1](https://github.com/ReVanced/revanced-api/compare/v1.4.0...v1.5.0-dev.1) (2024-11-06) + + +### Features + +* Move spec url to versioned path ([e871b23](https://github.com/ReVanced/revanced-api/commit/e871b23210798723c34bce93c7567d8fbcf4e060)) + # [1.4.0](https://github.com/ReVanced/revanced-api/compare/v1.3.0...v1.4.0) (2024-11-06) diff --git a/gradle.properties b/gradle.properties index 70d12814..63f84b82 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ org.gradle.parallel = true org.gradle.caching = true kotlin.code.style = official -version = 1.4.0 +version = 1.5.0-dev.1 From d5d9e04325fa93540be0438e7b51243e2aeeab3d Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Wed, 6 Nov 2024 05:39:27 +0100 Subject: [PATCH 3/6] feat: Simplify log pattern --- src/main/resources/logback.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 2d304dee..02a44238 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -1,7 +1,7 @@ - %d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + %d{YYYY-MM-dd HH:mm:ss.SSS} %-5level %msg%n From 55e3774f077cc05894057164e5a4b7cf7af6dda6 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 6 Nov 2024 04:41:55 +0000 Subject: [PATCH 4/6] chore: Release v1.5.0-dev.1 [skip ci] # [1.5.0-dev.1](https://github.com/ReVanced/revanced-api/compare/v1.4.0...v1.5.0-dev.1) (2024-11-06) ### Features * Move spec url to versioned path ([e871b23](https://github.com/ReVanced/revanced-api/commit/e871b23210798723c34bce93c7567d8fbcf4e060)) * Simplify log pattern ([d5d9e04](https://github.com/ReVanced/revanced-api/commit/d5d9e04325fa93540be0438e7b51243e2aeeab3d)) --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a56d787a..e48208d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ # [1.5.0-dev.1](https://github.com/ReVanced/revanced-api/compare/v1.4.0...v1.5.0-dev.1) (2024-11-06) +### Features + +* Move spec url to versioned path ([e871b23](https://github.com/ReVanced/revanced-api/commit/e871b23210798723c34bce93c7567d8fbcf4e060)) +* Simplify log pattern ([d5d9e04](https://github.com/ReVanced/revanced-api/commit/d5d9e04325fa93540be0438e7b51243e2aeeab3d)) + +# [1.5.0-dev.1](https://github.com/ReVanced/revanced-api/compare/v1.4.0...v1.5.0-dev.1) (2024-11-06) + + ### Features * Move spec url to versioned path ([e871b23](https://github.com/ReVanced/revanced-api/commit/e871b23210798723c34bce93c7567d8fbcf4e060)) From 58ba4cb11c789507826cd70ac548943a94da4223 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Wed, 6 Nov 2024 16:34:09 +0100 Subject: [PATCH 5/6] feat: Allow updating `createdAt` field for announcements --- src/main/kotlin/app/revanced/api/configuration/APISchema.kt | 1 + .../api/configuration/repository/AnnouncementRepository.kt | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/kotlin/app/revanced/api/configuration/APISchema.kt b/src/main/kotlin/app/revanced/api/configuration/APISchema.kt index c4432aeb..2fa588aa 100644 --- a/src/main/kotlin/app/revanced/api/configuration/APISchema.kt +++ b/src/main/kotlin/app/revanced/api/configuration/APISchema.kt @@ -63,6 +63,7 @@ class ApiAnnouncement( val attachments: List = emptyList(), // Using a list instead of a set because set semantics are unnecessary here. val tags: List = emptyList(), + val createdAt: LocalDateTime, val archivedAt: LocalDateTime? = null, val level: Int = 0, ) diff --git a/src/main/kotlin/app/revanced/api/configuration/repository/AnnouncementRepository.kt b/src/main/kotlin/app/revanced/api/configuration/repository/AnnouncementRepository.kt index 01d74e2b..6acfa29c 100644 --- a/src/main/kotlin/app/revanced/api/configuration/repository/AnnouncementRepository.kt +++ b/src/main/kotlin/app/revanced/api/configuration/repository/AnnouncementRepository.kt @@ -120,6 +120,7 @@ internal class AnnouncementRepository(private val database: Database) { it.author = new.author it.title = new.title it.content = new.content + it.createdAt = new.createdAt it.archivedAt = new.archivedAt it.level = new.level From b063b4daf2252df7860173a1a0f3c2005111bea0 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 6 Nov 2024 15:36:26 +0000 Subject: [PATCH 6/6] chore: Release v1.5.0-dev.2 [skip ci] # [1.5.0-dev.2](https://github.com/ReVanced/revanced-api/compare/v1.5.0-dev.1...v1.5.0-dev.2) (2024-11-06) ### Features * Allow updating `createdAt` field for announcements ([58ba4cb](https://github.com/ReVanced/revanced-api/commit/58ba4cb11c789507826cd70ac548943a94da4223)) * Simplify log pattern ([d5d9e04](https://github.com/ReVanced/revanced-api/commit/d5d9e04325fa93540be0438e7b51243e2aeeab3d)) --- CHANGELOG.md | 8 ++++++++ gradle.properties | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e48208d8..10cffffd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# [1.5.0-dev.2](https://github.com/ReVanced/revanced-api/compare/v1.5.0-dev.1...v1.5.0-dev.2) (2024-11-06) + + +### Features + +* Allow updating `createdAt` field for announcements ([58ba4cb](https://github.com/ReVanced/revanced-api/commit/58ba4cb11c789507826cd70ac548943a94da4223)) +* Simplify log pattern ([d5d9e04](https://github.com/ReVanced/revanced-api/commit/d5d9e04325fa93540be0438e7b51243e2aeeab3d)) + # [1.5.0-dev.1](https://github.com/ReVanced/revanced-api/compare/v1.4.0...v1.5.0-dev.1) (2024-11-06) diff --git a/gradle.properties b/gradle.properties index 63f84b82..67fc117e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ org.gradle.parallel = true org.gradle.caching = true kotlin.code.style = official -version = 1.5.0-dev.1 +version = 1.5.0-dev.2