feat(frontend): Struktur und Kommentare verfeinert, Mail-Service-Konfiguration erweitert
Signed-off-by: Stefan Mogeritsch <stefan.mo.co@gmail.com>
This commit is contained in:
+2
@@ -1,6 +1,8 @@
|
||||
package at.mocode.frontend.core.network
|
||||
|
||||
@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
|
||||
expect object PlatformConfig {
|
||||
fun resolveApiBaseUrl(): String
|
||||
fun resolveMailServiceUrl(): String
|
||||
fun resolveKeycloakUrl(): String
|
||||
}
|
||||
|
||||
+12
@@ -36,6 +36,18 @@ actual object PlatformConfig {
|
||||
return fallbackUrl
|
||||
}
|
||||
|
||||
actual fun resolveMailServiceUrl(): String {
|
||||
val fromGlobal = try {
|
||||
(globalScope.MAIL_SERVICE_URL as? String)?.trim().orEmpty()
|
||||
} catch (_: dynamic) {
|
||||
""
|
||||
}
|
||||
if (fromGlobal.isNotEmpty()) {
|
||||
return fromGlobal.removeSuffix("/")
|
||||
}
|
||||
return "http://localhost:8085"
|
||||
}
|
||||
|
||||
actual fun resolveKeycloakUrl(): String {
|
||||
// 1) Prefer a global JS variable (injected by main.kt via AppConfig)
|
||||
val fromGlobal = try {
|
||||
|
||||
+6
@@ -10,6 +10,12 @@ actual object PlatformConfig {
|
||||
return "http://localhost:8081"
|
||||
}
|
||||
|
||||
actual fun resolveMailServiceUrl(): String {
|
||||
val env = System.getenv("MAIL_SERVICE_URL")?.trim().orEmpty()
|
||||
if (env.isNotEmpty()) return env.removeSuffix("/")
|
||||
return "http://localhost:8085"
|
||||
}
|
||||
|
||||
actual fun resolveKeycloakUrl(): String {
|
||||
val env = System.getenv("KEYCLOAK_URL")?.trim().orEmpty()
|
||||
if (env.isNotEmpty()) return env.removeSuffix("/")
|
||||
|
||||
+16
@@ -6,6 +6,12 @@ package at.mocode.frontend.core.network
|
||||
|
||||
@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
|
||||
actual object PlatformConfig {
|
||||
actual fun resolveMailServiceUrl(): String {
|
||||
val fromGlobal = getGlobalMailServiceUrl()
|
||||
if (fromGlobal.isNotEmpty()) return fromGlobal.removeSuffix("/")
|
||||
return "http://localhost:8085"
|
||||
}
|
||||
|
||||
actual fun resolveKeycloakUrl(): String {
|
||||
val fromGlobal = getGlobalKeycloakUrl()
|
||||
if (fromGlobal.isNotEmpty()) return fromGlobal.removeSuffix("/")
|
||||
@@ -47,6 +53,16 @@ private fun getGlobalApiBaseUrl(): String = js(
|
||||
"""
|
||||
)
|
||||
|
||||
@OptIn(ExperimentalWasmJsInterop::class)
|
||||
private fun getGlobalMailServiceUrl(): String = js(
|
||||
"""
|
||||
(function() {
|
||||
var global = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== 'undefined' ? window : (typeof self !== 'undefined' ? self : {}));
|
||||
return (global.MAIL_SERVICE_URL && typeof global.MAIL_SERVICE_URL === 'string') ? global.MAIL_SERVICE_URL : "";
|
||||
})()
|
||||
"""
|
||||
)
|
||||
|
||||
@OptIn(ExperimentalWasmJsInterop::class)
|
||||
private fun getGlobalKeycloakUrl(): String = js(
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user