UI improvements, CLI fallbacks

This commit is contained in:
2026-08-24 17:07:19 +02:00
parent 462c6da965
commit 07225ae461
16 changed files with 464 additions and 170 deletions
+28
View File
@@ -7,11 +7,27 @@ plugins {
}
group = "com.jaytux.phoebench"
version = rootProject.version
repositories {
mavenCentral()
}
val versionDirectory = layout.buildDirectory.dir("generated/sources/version")
val generateVersion = tasks.register<Task>("serverVersion") {
doFirst {
val outFile = versionDirectory.get().file("com/jaytux/phoebench/server/Version.kt").asFile
outFile.parentFile.mkdirs()
outFile.writeText("""
package com.jaytux.phoebench.server
object ServerVersion {
const val VERSION="${rootProject.version}"
}
""".trimIndent())
}
}
dependencies {
implementation(libs.exposed.core)
implementation(libs.exposed.dao)
@@ -63,6 +79,18 @@ kotlin {
freeCompilerArgs.add("-Xcontext-parameters")
optIn.add("kotlin.uuid.ExperimentalUuidApi")
}
sourceSets {
val main by getting {
kotlin {
srcDir(versionDirectory)
}
}
}
tasks.compileKotlin {
dependsOn(generateVersion)
}
}
application {
@@ -25,24 +25,14 @@ import kotlin.uuid.Uuid
fun Application.module() {
DB.db
println("Entering module...")
println("Entering module for PhoeBench Server version ${ServerVersion.VERSION}...")
install(ContentNegotiation) {
json()
}
install(StatusPages) {
status(HttpStatusCode.Forbidden) { call, status ->
call.respond(status, ErrorResponse("Access Forbidden: CORS failed."))
}
status(HttpStatusCode.Unauthorized) { call, status ->
call.respond(status, ErrorResponse("Unauthorized/unauthenticated."))
}
}
install(SSE) {
//
}
install(SSE) {}
val allowLocalhost = environment.config.propertyOrNull("ktor.cors.enableLocalhostOn")?.getString() ?: "0"
val safeOrigin = environment.config.propertyOrNull("ktor.cors.browserOrigin")?.getString()
@@ -52,6 +42,7 @@ fun Application.module() {
allowMethod(HttpMethod.Patch)
allowMethod(HttpMethod.Get)
allowMethod(HttpMethod.Post)
allowHeader(HttpHeaders.Accept)
allowHeader(HttpHeaders.Authorization)
allowHeader(HttpHeaders.ContentType)
exposeHeader(HttpHeaders.ContentType)
@@ -76,6 +67,15 @@ fun Application.module() {
}
}
install(StatusPages) {
status(HttpStatusCode.Forbidden) { call, status ->
call.respond(status, ErrorResponse("Access Forbidden: CORS failed."))
}
status(HttpStatusCode.Unauthorized) { call, status ->
call.respond(status, ErrorResponse("Unauthorized/unauthenticated."))
}
}
install(AutoHeadResponse)
install(CallLogging)
@@ -0,0 +1 @@
org.slf4j.simpleLogger.log.io.ktor.server.plugins.cors=TRACE