2019-09-19 22:04:23 +02:00
package moe.kageru.kodeshare
import io.ktor.application.install
import io.ktor.features.DefaultHeaders
2019-09-22 18:26:28 +02:00
import io.ktor.locations.KtorExperimentalLocationsAPI
2019-09-19 22:04:23 +02:00
import io.ktor.locations.Locations
import io.ktor.routing.routing
import io.ktor.server.engine.embeddedServer
import io.ktor.server.netty.Netty
import moe.kageru.kodeshare.Routes.createRoutes
2019-09-29 09:51:15 +02:00
import moe.kageru.kodeshare.config.ServerSpec
import moe.kageru.kodeshare.config.config
import moe.kageru.kodeshare.persistence.PasteDao
2019-09-19 22:04:23 +02:00
2019-09-22 18:26:28 +02:00
@KtorExperimentalLocationsAPI
2019-09-19 22:04:23 +02:00
@ExperimentalStdlibApi
fun main ( ) {
2019-09-29 09:51:15 +02:00
/ *
* This is meant as a health check against the DB
* so we notice errors at startup ,
* not when first accessing it
* /
println ( PasteDao . select ( 1 ) ?. id )
val port = config [ ServerSpec . port ]
Log . info ( " Kodeshare running on port $port " )
embeddedServer ( Netty , port ) {
2019-09-19 22:04:23 +02:00
install ( DefaultHeaders )
install ( Locations )
routing {
createRoutes ( )
}
} . start ( wait = true )
}