From f7b19c043f2ec8c3b68ea78bc16e5ef9a130ad26 Mon Sep 17 00:00:00 2001 From: ZhuJHua <1624109111@qq.com> Date: Sun, 1 Dec 2024 02:31:33 +0800 Subject: [PATCH] feat(server): init server --- server/build.gradle.kts | 3 +++ server/gradle.properties | 1 + server/src/main/kotlin/cn/yooss/Frameworks.kt | 6 +----- server/src/main/kotlin/cn/yooss/HelloService.kt | 5 ----- server/src/test/kotlin/cn/yooss/ApplicationTest.kt | 10 ++-------- 5 files changed, 7 insertions(+), 18 deletions(-) delete mode 100644 server/src/main/kotlin/cn/yooss/HelloService.kt diff --git a/server/build.gradle.kts b/server/build.gradle.kts index 8603523..0036cf5 100644 --- a/server/build.gradle.kts +++ b/server/build.gradle.kts @@ -1,6 +1,7 @@ val koin_version: String by project val kotlin_version: String by project val logback_version: String by project +val mongodb_version: String by project plugins { kotlin("jvm") version "2.0.21" @@ -34,6 +35,8 @@ dependencies { implementation("io.ktor:ktor-server-netty-jvm") implementation("ch.qos.logback:logback-classic:$logback_version") implementation("io.ktor:ktor-server-config-yaml-jvm") + implementation("org.mongodb:mongodb-driver-kotlin-coroutine:$mongodb_version") testImplementation("io.ktor:ktor-server-test-host-jvm") testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version") + } diff --git a/server/gradle.properties b/server/gradle.properties index dd47831..0b46d18 100644 --- a/server/gradle.properties +++ b/server/gradle.properties @@ -3,3 +3,4 @@ koin_version=3.5.6 kotlin_version=2.0.21 ktor_version=3.0.1 logback_version=1.4.14 +mongodb_version=5.2.0 \ No newline at end of file diff --git a/server/src/main/kotlin/cn/yooss/Frameworks.kt b/server/src/main/kotlin/cn/yooss/Frameworks.kt index ec59b4d..6146308 100644 --- a/server/src/main/kotlin/cn/yooss/Frameworks.kt +++ b/server/src/main/kotlin/cn/yooss/Frameworks.kt @@ -9,11 +9,7 @@ fun Application.configureFrameworks() { install(Koin) { slf4jLogger() modules(module { - single { - HelloService { - println(environment.log.info("Hello, World!")) - } - } + }) } } diff --git a/server/src/main/kotlin/cn/yooss/HelloService.kt b/server/src/main/kotlin/cn/yooss/HelloService.kt deleted file mode 100644 index 772c01d..0000000 --- a/server/src/main/kotlin/cn/yooss/HelloService.kt +++ /dev/null @@ -1,5 +0,0 @@ -package cn.yooss - -fun interface HelloService { - fun sayHello() -} diff --git a/server/src/test/kotlin/cn/yooss/ApplicationTest.kt b/server/src/test/kotlin/cn/yooss/ApplicationTest.kt index 45f80ab..98ae731 100644 --- a/server/src/test/kotlin/cn/yooss/ApplicationTest.kt +++ b/server/src/test/kotlin/cn/yooss/ApplicationTest.kt @@ -1,10 +1,7 @@ package cn.yooss -import io.ktor.client.request.* -import io.ktor.client.statement.* -import io.ktor.http.* import io.ktor.server.testing.* -import kotlin.test.* +import kotlin.test.Test class ApplicationTest { @Test @@ -12,9 +9,6 @@ class ApplicationTest { application { configureRouting() } - client.get("/").apply { - assertEquals(HttpStatusCode.OK, status) - assertEquals("Hello World!", bodyAsText()) - } + } }