From 9e8b42d8626520667996d34231e2b40939a04d9e Mon Sep 17 00:00:00 2001 From: luevard Date: Mon, 15 Jan 2024 22:23:56 +0100 Subject: [PATCH] :sparkles: Try to add database container --- Sources/src/main/kotlin/allin/Application.kt | 8 ++++++++ Sources/src/main/kotlin/allin/routing/UserRouter.kt | 2 -- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Sources/src/main/kotlin/allin/Application.kt b/Sources/src/main/kotlin/allin/Application.kt index 657f576..f8fecef 100644 --- a/Sources/src/main/kotlin/allin/Application.kt +++ b/Sources/src/main/kotlin/allin/Application.kt @@ -14,6 +14,13 @@ import io.ktor.server.config.* import io.ktor.server.engine.* import io.ktor.server.netty.* import io.ktor.server.plugins.contentnegotiation.* +import org.ktorm.database.Database + +val db_database=System.getenv().get("POSTGRES_DB") +val db_user=System.getenv().get("POSTGRES_USER") +val db_password=System.getenv().get("POSTGRES_PASSWORD") +val database = Database.connect("jdbc:postgresql:$db_database", user = db_user, password = db_password) + fun main() { embeddedServer(Netty, port = 8080, host = "0.0.0.0") { @@ -24,6 +31,7 @@ fun main() { private fun Application.extracted() { val config = HoconApplicationConfig(ConfigFactory.load()) val tokenManager = TokenManager.getInstance(config) + println("jdbc:postgresql:$db_database$db_user$db_password") authentication { jwt { verifier(tokenManager.verifyJWTToken()) diff --git a/Sources/src/main/kotlin/allin/routing/UserRouter.kt b/Sources/src/main/kotlin/allin/routing/UserRouter.kt index b89af65..4a70e06 100644 --- a/Sources/src/main/kotlin/allin/routing/UserRouter.kt +++ b/Sources/src/main/kotlin/allin/routing/UserRouter.kt @@ -24,8 +24,6 @@ val RegexCheckerUser = AppConfig.regexChecker val CryptManagerUser = AppConfig.cryptManager val tokenManagerUser = AppConfig.tokenManager const val DEFAULT_COINS = 500 -val database = Database.connect("jdbc:postgresql://localhost:5432/Allin", user = "postgres", password = "lulu") - fun Application.UserRouter() { routing {