@file:Suppress("ktlint:standard:no-wildcard-imports") package observer.nelle.nelleObserverBackend import io.github.oshai.kotlinlogging.KotlinLogging 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 import observer.nelle.nelleObserverBackend.plugins.configureRouting val logger = KotlinLogging.logger("nelle.observer API") fun main(args: Array): Unit = EngineMain.main(args) 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) } }