Skip to content

Commit

Permalink
chore: Merge branch dev to main(#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Nov 6, 2024
2 parents e22ec16 + b063b4d commit 7f9159f
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 9 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# [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)


### 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))

# [1.4.0](https://github.com/ReVanced/revanced-api/compare/v1.3.0...v1.4.0) (2024-11-06)


Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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.2
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class ApiAnnouncement(
val attachments: List<String> = emptyList(),
// Using a list instead of a set because set semantics are unnecessary here.
val tags: List<String> = emptyList(),
val createdAt: LocalDateTime,
val archivedAt: LocalDateTime? = null,
val level: Int = 0,
)
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/app/revanced/api/configuration/HTTP.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.koin.ktor.ext.get
import kotlin.time.Duration.Companion.minutes

fun Application.configureHTTP() {
val configurationRepository = get<ConfigurationRepository>()
val configuration = get<ConfigurationRepository>()

install(CORS) {
HttpMethod.DefaultMethods.minus(HttpMethod.Options).forEach(::allowMethod)
Expand All @@ -22,7 +22,7 @@ fun Application.configureHTTP() {

allowCredentials = true

configurationRepository.corsAllowedHosts.forEach { host ->
configuration.corsAllowedHosts.forEach { host ->
allowHost(host = host, schemes = listOf("https"))
}
}
Expand Down
16 changes: 13 additions & 3 deletions src/main/kotlin/app/revanced/api/configuration/OpenAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<ConfigurationRepository>()
val configuration = koinGet<ConfigurationRepository>()

install(NotarizedApplication()) {
openApiJson = {
route("/${configuration.apiVersion}/openapi.json") {
get {
call.respond(application.attributes[KompendiumAttributes.openApiSpec])
}
}
}
spec = OpenApiSpec(
info = Info(
title = "ReVanced API",
Expand All @@ -41,7 +51,7 @@ internal fun Application.configureOpenAPI() {
),
).apply {
servers += Server(
url = URI(configurationRepository.endpoint),
url = URI(configuration.endpoint),
description = "ReVanced API server",
)
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/app/revanced/api/configuration/Routing.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
<pattern>%d{YYYY-MM-dd HH:mm:ss.SSS} %-5level %msg%n</pattern>
</encoder>
</appender>
<root level="\${LOG_LEVEL:-INFO}">
Expand Down

0 comments on commit 7f9159f

Please sign in to comment.