diff --git a/src/main/kotlin/dev/usbharu/hideout/Application.kt b/src/main/kotlin/dev/usbharu/hideout/Application.kt index e5b64c34..e67e5b60 100644 --- a/src/main/kotlin/dev/usbharu/hideout/Application.kt +++ b/src/main/kotlin/dev/usbharu/hideout/Application.kt @@ -25,8 +25,7 @@ import org.jetbrains.exposed.sql.Database import org.koin.ktor.ext.inject import java.util.* -fun main(args: Array): Unit = - io.ktor.server.netty.EngineMain.main(args) +fun main(args: Array): Unit = io.ktor.server.netty.EngineMain.main(args) @Suppress("unused") // application.conf references the main function. This annotation prevents the IDE from marking it as unused. fun Application.module() { @@ -34,8 +33,8 @@ fun Application.module() { single { Database.connect( - url = "jdbc:h2:./test;MODE=POSTGRESQL", - driver = "org.h2.Driver", + url = environment.config.property("hideout.database.url").getString(), + driver = environment.config.property("hideout.database.driver").getString(), ) } single { diff --git a/src/main/kotlin/dev/usbharu/hideout/config/Config.kt b/src/main/kotlin/dev/usbharu/hideout/config/Config.kt index 02983747..fc4fe21b 100644 --- a/src/main/kotlin/dev/usbharu/hideout/config/Config.kt +++ b/src/main/kotlin/dev/usbharu/hideout/config/Config.kt @@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper object Config { - var configData:ConfigData = ConfigData("", jacksonObjectMapper()) + var configData: ConfigData = ConfigData() } -data class ConfigData(val hostname:String,val objectMapper: ObjectMapper) +data class ConfigData(val hostname: String = "", val objectMapper: ObjectMapper = jacksonObjectMapper()) diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 94b0ac0f..0a1d02eb 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -13,4 +13,10 @@ ktor { hideout { hostname = "https://localhost:8080" hostname = ${?HOSTNAME} + database { + url = "jdbc:h2:./test;MODE=POSTGRESQL" + driver = "org.h2.Driver" + username = "" + password = "" + } }