Try to add database container

pull/3/head
Lucas EVARD 1 year ago
parent bc1207e6d8
commit d8ff355d3e

@ -1,17 +1,26 @@
package allin
import allin.routing.BasicRouting
import allin.routing.BetRouter
import allin.routing.ParticipationRouter
import allin.routing.UserRouter
import allin.utils.TokenManager
import com.typesafe.config.ConfigFactory
import io.ktor.serialization.kotlinx.json.*
import io.ktor.server.application.*
import io.ktor.server.auth.*
import io.ktor.server.auth.jwt.*
import io.ktor.server.config.*
import io.ktor.server.engine.*
import io.ktor.server.netty.*
import io.ktor.server.plugins.contentnegotiation.*
import allin.utils.TokenManager
import io.ktor.server.auth.*
import io.ktor.server.auth.jwt.*
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") {
@ -22,12 +31,13 @@ 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())
realm=config.property("realm").getString()
realm = config.property("realm").getString()
validate { jwtCredential ->
if(jwtCredential.payload.getClaim("username").asString().isNotEmpty())
if (jwtCredential.payload.getClaim("username").asString().isNotEmpty())
JWTPrincipal(jwtCredential.payload)
else null
}
@ -39,4 +49,5 @@ private fun Application.extracted() {
BasicRouting()
UserRouter()
BetRouter()
ParticipationRouter()
}

@ -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 {

Loading…
Cancel
Save