mirror of
https://github.com/ZhuJHua/moodiary.git
synced 2026-04-04 23:29:01 +08:00
feat(server): init server
This commit is contained in:
@@ -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")
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -9,11 +9,7 @@ fun Application.configureFrameworks() {
|
||||
install(Koin) {
|
||||
slf4jLogger()
|
||||
modules(module {
|
||||
single<HelloService> {
|
||||
HelloService {
|
||||
println(environment.log.info("Hello, World!"))
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package cn.yooss
|
||||
|
||||
fun interface HelloService {
|
||||
fun sayHello()
|
||||
}
|
||||
@@ -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())
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user