diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 283905a..e3c8f3e 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,7 +4,12 @@ updates: directory: "/api" schedule: interval: "weekly" + groups: + ktor: + patterns: ["io.ktor*"] + database: + patterns: [ "org.jdbi*", "org.flyway*", "org.postgresql*" ] - package-ecosystem: "docker" directory: "/api" schedule: - interval: "weekly" + interval: "weekly" \ No newline at end of file diff --git a/api/.editorconfig b/api/.editorconfig new file mode 100644 index 0000000..8a7eb1e --- /dev/null +++ b/api/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*.{kt,kts}] +ktlint_code_style = ktlint_official +ktlint_standard_multiline-expression-wrapping = disabled +ktlint_standard_chain-method-continuation = disabled +ktlint_standard_function-signature = disabled +ktlint_standard_function-expression-body = disabled +max_line_length = 120 \ No newline at end of file diff --git a/api/app/.editorconfig b/api/app/.editorconfig deleted file mode 100644 index 9a0f3b7..0000000 --- a/api/app/.editorconfig +++ /dev/null @@ -1,5 +0,0 @@ -[*.{kt,kts}] -ktlint_standard_no-wildcard-imports = disabled -ktlint_standard_multiline-expression-wrapping = disabled -ktlint_standard_string-template-indent = disabled -max_line_length = 120 \ No newline at end of file diff --git a/api/app/build.gradle.kts b/api/app/build.gradle.kts index e56dc37..ae398d6 100644 --- a/api/app/build.gradle.kts +++ b/api/app/build.gradle.kts @@ -28,10 +28,6 @@ testing { val test by getting(JvmTestSuite::class) { useKotlinTest("2.0.0") testType = TestSuiteType.UNIT_TEST - - dependencies { - implementation("io.ktor:ktor-server-test-host") - } } register("integrationTest") { @@ -40,6 +36,8 @@ testing { dependencies { implementation(project()) + implementation(platform("io.ktor:ktor-bom:3.0.0-beta-2")) + implementation("io.ktor:ktor-server-test-host") } targets { @@ -73,6 +71,7 @@ tasks.withType { } dependencies { + implementation(platform("io.ktor:ktor-bom:3.0.0-beta-2")) implementation("io.ktor:ktor-server-core") implementation("io.ktor:ktor-server-netty") implementation("io.ktor:ktor-server-call-logging") @@ -96,3 +95,8 @@ dependencies { application { mainClass = "com.photofox.MainKt" } + +configure { + version.set("1.3.1") + verbose.set(true) +} diff --git a/api/app/src/integrationTest/kotlin/com/photofox/HealthSenseCheck.kt b/api/app/src/integrationTest/kotlin/com/photofox/HealthSenseCheck.kt new file mode 100644 index 0000000..3a76259 --- /dev/null +++ b/api/app/src/integrationTest/kotlin/com/photofox/HealthSenseCheck.kt @@ -0,0 +1,19 @@ +package com.photofox + +import io.ktor.client.request.get +import io.ktor.http.HttpStatusCode +import io.ktor.server.testing.testApplication +import kotlin.test.Test +import kotlin.test.assertEquals + +class HealthSenseCheck { + @Test + fun `health check returns 2xx`() = testApplication { + application { + module() + } + + val response = client.get("/api/health") + assertEquals(HttpStatusCode.OK, response.status) + } +} diff --git a/api/app/src/main/kotlin/com/photofox/Main.kt b/api/app/src/main/kotlin/com/photofox/Main.kt index 74364fb..406f955 100644 --- a/api/app/src/main/kotlin/com/photofox/Main.kt +++ b/api/app/src/main/kotlin/com/photofox/Main.kt @@ -124,10 +124,7 @@ private fun Application.configureRouting() { } } -suspend fun RoutingCall.respondPage( - pageTemplateName: String, - viewModel: ViewModel, -) { +suspend fun RoutingCall.respondPage(pageTemplateName: String, viewModel: ViewModel) { return this.respond( PageResponse( makePageTemplatePath(pageTemplateName), diff --git a/api/app/src/main/kotlin/com/photofox/page/PageResponsePlugin.kt b/api/app/src/main/kotlin/com/photofox/page/PageResponsePlugin.kt index b0ebe77..82931e5 100644 --- a/api/app/src/main/kotlin/com/photofox/page/PageResponsePlugin.kt +++ b/api/app/src/main/kotlin/com/photofox/page/PageResponsePlugin.kt @@ -15,10 +15,7 @@ class PageResponsePlugin { companion object Plugin : BaseApplicationPlugin { override val key = AttributeKey("PageResponse") - override fun install( - pipeline: ApplicationCallPipeline, - configure: Any.() -> Unit, - ): Plugin { + override fun install(pipeline: ApplicationCallPipeline, configure: Any.() -> Unit): Plugin { pipeline.sendPipeline.intercept(ApplicationSendPipeline.Before) { value -> if (value is PageResponse<*>) { context.response.cacheControl( diff --git a/api/app/static b/api/app/static new file mode 120000 index 0000000..4dab164 --- /dev/null +++ b/api/app/static @@ -0,0 +1 @@ +../static \ No newline at end of file diff --git a/api/app/templates b/api/app/templates new file mode 120000 index 0000000..564a409 --- /dev/null +++ b/api/app/templates @@ -0,0 +1 @@ +../templates \ No newline at end of file