|
|
|
@ -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,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())
|
|
|
|
@ -39,4 +49,5 @@ private fun Application.extracted() {
|
|
|
|
|
BasicRouting()
|
|
|
|
|
UserRouter()
|
|
|
|
|
BetRouter()
|
|
|
|
|
ParticipationRouter()
|
|
|
|
|
}
|
|
|
|
|