2021-08-11 14:40:05 +02:00
|
|
|
package com.kmalbz
|
|
|
|
|
2021-08-16 15:00:08 +02:00
|
|
|
import com.kmalbz.api.route.SampleServiceServer
|
2021-08-11 14:40:05 +02:00
|
|
|
import io.ktor.application.*
|
|
|
|
import io.ktor.response.*
|
|
|
|
import io.ktor.routing.*
|
|
|
|
import io.ktor.http.*
|
|
|
|
import io.ktor.gson.*
|
|
|
|
import io.ktor.features.*
|
|
|
|
import org.apache.http.HttpException
|
|
|
|
import com.kmalbz.database.DatabaseFactory
|
|
|
|
import com.kmalbz.database.dao.SampleObjects
|
2021-08-11 16:50:34 +02:00
|
|
|
import io.ktor.util.*
|
2021-08-11 14:40:05 +02:00
|
|
|
import org.jetbrains.exposed.sql.SchemaUtils
|
|
|
|
import org.jetbrains.exposed.sql.transactions.transaction
|
|
|
|
import org.koin.ktor.ext.Koin
|
|
|
|
|
|
|
|
fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)
|
|
|
|
|
|
|
|
@KtorExperimentalAPI
|
|
|
|
@Suppress("unused") // Referenced in application.conf
|
|
|
|
fun Application.module() {
|
|
|
|
install(ContentNegotiation) {
|
|
|
|
gson {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
install(Koin) {
|
|
|
|
printLogger()
|
|
|
|
modules(com.kmalbz.di.injectionModule)
|
|
|
|
}
|
|
|
|
|
|
|
|
DatabaseFactory.init()
|
|
|
|
transaction{
|
|
|
|
SchemaUtils.create(SampleObjects)
|
|
|
|
}
|
|
|
|
|
|
|
|
routing {
|
|
|
|
install(StatusPages) {
|
|
|
|
exception<HttpException> {
|
|
|
|
call.respond(HttpStatusCode.BadRequest)
|
|
|
|
}
|
|
|
|
|
|
|
|
exception<IllegalStateException> {
|
|
|
|
call.respond(HttpStatusCode.NotAcceptable)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-16 15:00:08 +02:00
|
|
|
SampleServiceServer().apply {
|
2021-08-11 14:40:05 +02:00
|
|
|
registerOutput()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|