diff --git a/backend/build.gradle.kts b/backend/build.gradle.kts index d386e1b..201a6b1 100644 --- a/backend/build.gradle.kts +++ b/backend/build.gradle.kts @@ -16,8 +16,9 @@ dependencies { with(Deps.Ktor) { implementation(serverCore) implementation(serverNetty) - //implementation(serialization) implementation(websockets) + implementation(serverContentNegotiation) + implementation(json) } with(Deps.Log) { diff --git a/backend/src/main/kotlin/Server.kt b/backend/src/main/kotlin/Server.kt index c227d6f..5160b81 100644 --- a/backend/src/main/kotlin/Server.kt +++ b/backend/src/main/kotlin/Server.kt @@ -2,14 +2,13 @@ import com.surrus.common.di.initKoin import com.surrus.common.remote.Assignment import com.surrus.common.remote.AstroResult import com.surrus.common.remote.PeopleInSpaceApi -import io.ktor.application.* -import io.ktor.features.* -import io.ktor.http.* -import io.ktor.response.* -import io.ktor.routing.* -import io.ktor.serialization.* +import io.ktor.server.application.* +import io.ktor.serialization.kotlinx.json.* import io.ktor.server.engine.* import io.ktor.server.netty.* +import io.ktor.server.plugins.* +import io.ktor.server.response.* +import io.ktor.server.routing.* fun main() { val koin = initKoin(enableNetworkLogs = true).koin @@ -22,20 +21,6 @@ fun main() { json() } - install(CORS) { - method(HttpMethod.Options) - method(HttpMethod.Put) - method(HttpMethod.Delete) - method(HttpMethod.Patch) - header(HttpHeaders.Authorization) - header(HttpHeaders.ContentType) - header(HttpHeaders.AccessControlAllowOrigin) - // header("any header") if you want to add any header - allowCredentials = true - allowNonSimpleContentTypes = true - anyHost() - } - routing { get("/astros.json") { diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index 6c26585..4dc07dd 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -112,6 +112,8 @@ object Deps { const val contentNegotiation = "io.ktor:ktor-client-content-negotiation:${Versions.ktor}" const val json = "io.ktor:ktor-serialization-kotlinx-json:${Versions.ktor}" + const val serverContentNegotiation = "io.ktor:ktor-server-content-negotiation:${Versions.ktor}" + const val websockets = "io.ktor:ktor-websockets:${Versions.ktor}" const val clientCore = "io.ktor:ktor-client-core:${Versions.ktor}" const val clientJson = "io.ktor:ktor-client-json:${Versions.ktor}" diff --git a/settings.gradle.kts b/settings.gradle.kts index 9af0721..2734517 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -11,5 +11,5 @@ rootProject.name = "PeopleInSpace" include(":app", ":common", ":compose-desktop") include(":web") include(":compose-web") -//include(":backend") +include(":backend") include(":wearApp")