34 lines
995 B
Kotlin
34 lines
995 B
Kotlin
package moe.kageru.kodeshare
|
|
|
|
import io.ktor.application.install
|
|
import io.ktor.features.DefaultHeaders
|
|
import io.ktor.locations.KtorExperimentalLocationsAPI
|
|
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
|
|
import moe.kageru.kodeshare.config.ServerSpec
|
|
import moe.kageru.kodeshare.config.config
|
|
import moe.kageru.kodeshare.persistence.PasteDao
|
|
|
|
@KtorExperimentalLocationsAPI
|
|
@ExperimentalStdlibApi
|
|
fun main() {
|
|
/*
|
|
* 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) {
|
|
install(DefaultHeaders)
|
|
install(Locations)
|
|
routing {
|
|
createRoutes()
|
|
}
|
|
}.start(wait = true)
|
|
}
|