server/src/main/kotlin/.../routes/InventoryRoutes.kt: - GET /api/inventory: returns full inventory as JSON - PUT /api/inventory: full-sync replaces entire server inventory server/src/main/kotlin/.../plugins/StatusPages.kt: - Structured error handling via Ktor StatusPages plugin - BadRequestException, SerializationException, IllegalArgumentException → 400 - Unhandled exceptions → 500 with logging server/src/main/kotlin/.../plugins/CallLogging.kt: - Request logging via Ktor CallLogging plugin (INFO level) server/src/main/kotlin/.../model/ErrorResponse.kt: - Serializable error response DTO (status + message) server/src/main/kotlin/.../plugins/Routing.kt: - Health endpoint moved from /health to /api/health - Inventory routes mounted under /api/inventory server/src/main/kotlin/.../Application.kt: - Added configurePlugins() for testability (DB init separate) - StatusPages and CallLogging plugins configured server/src/test/.../ApplicationTest.kt: - 8 endpoint tests using Ktor TestApplication with in-memory H2 - Tests: health, 404, empty GET, PUT valid, PUT+GET roundtrip, invalid JSON → 400, data replacement, JSON content type Closes #42
45 lines
1.1 KiB
Text
45 lines
1.1 KiB
Text
plugins {
|
|
alias(libs.plugins.kotlin.jvm)
|
|
alias(libs.plugins.kotlin.serialization)
|
|
alias(libs.plugins.ktor)
|
|
}
|
|
|
|
application {
|
|
mainClass.set("de.krisenvorrat.server.ApplicationKt")
|
|
}
|
|
|
|
ktor {
|
|
fatJar {
|
|
archiveFileName.set("server.jar")
|
|
}
|
|
}
|
|
|
|
java {
|
|
sourceCompatibility = JavaVersion.VERSION_11
|
|
targetCompatibility = JavaVersion.VERSION_11
|
|
}
|
|
|
|
kotlin {
|
|
compilerOptions {
|
|
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_11)
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation(project(":shared"))
|
|
|
|
implementation(libs.ktor.server.core)
|
|
implementation(libs.ktor.server.netty)
|
|
implementation(libs.ktor.server.content.negotiation)
|
|
implementation(libs.ktor.server.status.pages)
|
|
implementation(libs.ktor.server.call.logging)
|
|
implementation(libs.ktor.serialization.kotlinx.json)
|
|
implementation(libs.logback.classic)
|
|
implementation(libs.exposed.core)
|
|
implementation(libs.exposed.jdbc)
|
|
implementation(libs.h2.database)
|
|
|
|
testImplementation(libs.ktor.server.test.host)
|
|
testImplementation(libs.junit)
|
|
testImplementation(libs.kotlinx.serialization.json)
|
|
}
|