@file:Suppress("ktlint:standard:no-wildcard-imports") package observer.nelle.personalSiteAPI 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.engine.* 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.personalSiteAPI.plugins.configureRouting fun main(args: Array) { embeddedServer( Netty, port = 7879, // This is the port on which Ktor is listening host = "0.0.0.0", module = Application::module, ).start(wait = true) } 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) } }