2024-09-15 19:50:24 -06:00
|
|
|
@file:Suppress("ktlint:standard:no-wildcard-imports")
|
|
|
|
|
2024-09-15 21:17:29 -06:00
|
|
|
package observer.nelle.nelleObserverBackend
|
2024-09-15 19:50:24 -06:00
|
|
|
|
|
|
|
import io.ktor.client.*
|
|
|
|
import io.ktor.client.engine.cio.*
|
|
|
|
import io.ktor.client.plugins.auth.*
|
|
|
|
import io.ktor.client.plugins.auth.providers.*
|
|
|
|
import io.ktor.http.*
|
|
|
|
import io.ktor.server.application.*
|
|
|
|
import io.ktor.server.netty.*
|
|
|
|
import io.ktor.server.plugins.contentnegotiation.*
|
|
|
|
import io.ktor.server.plugins.cors.routing.*
|
|
|
|
import kotlinx.coroutines.runBlocking
|
2024-09-15 21:17:29 -06:00
|
|
|
import observer.nelle.nelleObserverBackend.plugins.configureRouting
|
2024-09-15 19:50:24 -06:00
|
|
|
|
2024-09-15 21:53:53 -06:00
|
|
|
fun main(args: Array<String>): Unit = EngineMain.main(args)
|
2024-09-15 19:50:24 -06:00
|
|
|
|
|
|
|
fun Application.module() {
|
|
|
|
install(ContentNegotiation)
|
|
|
|
install(CORS) {
|
|
|
|
allowMethod(HttpMethod.Options)
|
|
|
|
allowMethod(HttpMethod.Post)
|
|
|
|
allowMethod(HttpMethod.Get)
|
|
|
|
allowHeader(HttpHeaders.AccessControlAllowOrigin)
|
|
|
|
allowHeader(HttpHeaders.ContentType)
|
|
|
|
anyHost()
|
|
|
|
}
|
|
|
|
runBlocking {
|
|
|
|
val client =
|
|
|
|
HttpClient(CIO) {
|
|
|
|
// authentication setup
|
|
|
|
install(Auth) {
|
|
|
|
bearer {
|
|
|
|
loadTokens {
|
|
|
|
BearerTokens(Config().botToken, Config().botToken)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
configureRouting(client)
|
|
|
|
}
|
|
|
|
}
|