refactor(ping-service): remove CORS configuration from code, restructure modules, and update Gradle dependencies
Migrated CORS settings from code to `application.yaml` for better separation of concerns. Integrated `ping-api` into the new `contracts` module for improved modularity. Updated Gradle scripts and dependencies accordingly to reflect the new project structure.
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
plugins {
|
||||
alias(libs.plugins.kotlinMultiplatform)
|
||||
alias(libs.plugins.kotlinSerialization)
|
||||
}
|
||||
|
||||
group = "at.mocode"
|
||||
version = "1.0.0"
|
||||
|
||||
kotlin {
|
||||
// Toolchain is now handled centrally in the root build.gradle.kts
|
||||
|
||||
// JVM target for backend usage
|
||||
jvm()
|
||||
|
||||
// JS target for frontend usage (Compose/Browser)
|
||||
js {
|
||||
browser()
|
||||
// no need for binaries.executable() in a library
|
||||
}
|
||||
|
||||
// Wasm enabled by default
|
||||
@OptIn(org.jetbrains.kotlin.gradle.ExperimentalWasmDsl::class)
|
||||
wasmJs {
|
||||
browser()
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
implementation(libs.kotlinx.serialization.json)
|
||||
}
|
||||
}
|
||||
commonTest {
|
||||
dependencies {
|
||||
implementation(libs.kotlin.test)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package at.mocode.ping.api
|
||||
|
||||
interface PingApi {
|
||||
suspend fun simplePing(): PingResponse
|
||||
suspend fun enhancedPing(simulate: Boolean = false): EnhancedPingResponse
|
||||
suspend fun healthCheck(): HealthResponse
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package at.mocode.ping.api
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class PingResponse(val status: String, val timestamp: String, val service: String)
|
||||
|
||||
@Serializable
|
||||
data class EnhancedPingResponse(
|
||||
val status: String,
|
||||
val timestamp: String,
|
||||
val service: String,
|
||||
val circuitBreakerState: String,
|
||||
val responseTime: Long
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class HealthResponse(
|
||||
val status: String,
|
||||
val timestamp: String,
|
||||
val service: String,
|
||||
val healthy: Boolean
|
||||
)
|
||||
|
||||
@@ -14,7 +14,7 @@ kotlin {
|
||||
|
||||
dependencies {
|
||||
// === Project Dependencies ===
|
||||
implementation(projects.backend.services.ping.pingApi)
|
||||
implementation(projects.contracts.pingApi)
|
||||
implementation(projects.platform.platformDependencies)
|
||||
// NEU: Zugriff auf die verschobenen DatabaseUtils
|
||||
implementation(projects.backend.infrastructure.persistence)
|
||||
|
||||
+1
-22
@@ -2,33 +2,12 @@ package at.mocode.ping
|
||||
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||
import org.springframework.boot.runApplication
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.context.annotation.EnableAspectJAutoProxy
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
|
||||
|
||||
@SpringBootApplication
|
||||
// Scannt explizit alle Sub-Packages (infrastructure, application, domain)
|
||||
@EnableAspectJAutoProxy
|
||||
class PingServiceApplication {
|
||||
|
||||
@Bean
|
||||
fun corsConfigurer(): WebMvcConfigurer {
|
||||
return object : WebMvcConfigurer {
|
||||
override fun addCorsMappings(registry: org.springframework.web.servlet.config.annotation.CorsRegistry) {
|
||||
registry.addMapping("/**")
|
||||
.allowedOriginPatterns("http://localhost:*")
|
||||
.allowedOrigins("http://localhost:8080",
|
||||
"http://localhost:8083",
|
||||
"http://localhost:4000"
|
||||
)
|
||||
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
|
||||
.allowedHeaders("*")
|
||||
.allowCredentials(true)
|
||||
.maxAge(3600)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
class PingServiceApplication
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
runApplication<PingServiceApplication>(*args)
|
||||
|
||||
@@ -42,6 +42,17 @@ spring:
|
||||
health-check-interval: 10s
|
||||
instance-id: ${spring.application.name}-${server.port}-${random.uuid}
|
||||
|
||||
# CORS-Konfiguration ausgelagert aus dem Code
|
||||
web:
|
||||
cors:
|
||||
mappings:
|
||||
"/**":
|
||||
allowed-origin-patterns: "http://localhost:*,http://127.0.0.1:*"
|
||||
allowed-methods: "GET,POST,PUT,DELETE,OPTIONS"
|
||||
allowed-headers: "*"
|
||||
allow-credentials: true
|
||||
max-age: 3600
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
|
||||
Reference in New Issue
Block a user