From 368aa8580e05161dab2fe42c4434436c8d7ce764 Mon Sep 17 00:00:00 2001 From: Asoji Date: Mon, 9 Sep 2024 00:34:44 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20unfriendly=20text=20for=20an=20http?= =?UTF-8?q?=20server?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Writerside/cfg/static/custom.css | 1 - build.gradle.kts | 7 ++++++ gradle/libs.versions.toml | 22 ++++++++++++------- .../kotlin/one/devos/yiski/runner/Routing.kt | 13 +++++++++++ .../one/devos/yiski/runner/YiskiRunner.kt | 11 +++++++++- 5 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 src/main/kotlin/one/devos/yiski/runner/Routing.kt diff --git a/Writerside/cfg/static/custom.css b/Writerside/cfg/static/custom.css index ec0cfb4..372b110 100644 --- a/Writerside/cfg/static/custom.css +++ b/Writerside/cfg/static/custom.css @@ -1,4 +1,3 @@ -@import "https://tilomitra.github.io/infinite/infinite.css"; @import "https://stijndv.com/fonts/Eudoxus-Sans.css"; @import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap'); diff --git a/build.gradle.kts b/build.gradle.kts index bc1b8e9..fc9a41e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,6 +6,7 @@ plugins { id("com.gradleup.shadow") id("one.devos.yiski.build") java + alias(libs.plugins.ktor) } group = "one.devos" @@ -117,3 +118,9 @@ subprojects { } } +application { // apparently needed for ktor? ok. + mainClass.set("one.devos.yiski.runner.YiskiRunnerKt") + + val isDevelopment: Boolean = project.ext.has("development") + applicationDefaultJvmArgs = listOf("-Dio.ktor.development=$isDevelopment") +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0db70a3..d268d90 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,24 +2,24 @@ # Aviation aviation = "7d1dcef7" # Exposed -exposed = "0.52.0" +exposed = "0.54.0" # GitHub API github-api = "1.323" # JDA jda = "5.0.1" jda-ktx = "0.12.0" # Ktor -ktor = "2.3.11" -ktoml = "0.5.1" +ktor = "2.3.12" +ktoml = "0.5.2" # Kotlin -kotlinx-coroutines = "1.8.1" -kotlinx-serialization = "1.6.3" -kotlin-logging = "5.1.0" +kotlinx-coroutines = "1.9.0-RC.2" +kotlinx-serialization = "1.7.2" +kotlin-logging = "7.0.0" # Lavalink lavalink-client = "3.0.0" pcm-audio-utils = "0.1.0" # Logback -logback = "1.5.6" +logback = "1.5.8" # OkHttp okhttp = "4.12.0" # PostgresQL @@ -51,6 +51,9 @@ jda-ktx = { module = "club.minnced:jda-ktx", version.ref = "jda-ktx" } ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" } ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" } ktor-client-cio-jvm = { module = "io.ktor:ktor-client-cio-jvm", version.ref = "ktor" } +ktor-server-core = { module = "io.ktor:ktor-server-core-jvm", version.ref = "ktor" } +ktor-server-cio = { module = "io.ktor:ktor-server-cio-jvm", version.ref = "ktor" } +ktor-server-config-yaml = { module = "io.ktor:ktor-server-config-yaml", version.ref = "ktor" } # Ktoml ktoml-core = { module = "com.akuleshov7:ktoml-core", version.ref = "ktoml" } ktoml-file = { module = "com.akuleshov7:ktoml-file", version.ref = "ktoml" } @@ -106,7 +109,10 @@ kotlinx = [ ktor = [ "ktor-client-core", "ktor-client-cio", - "ktor-client-cio-jvm" + "ktor-client-cio-jvm", + "ktor-server-core", + "ktor-server-cio", + "ktor-server-config-yaml" ] ktoml = [ "ktoml-core", diff --git a/src/main/kotlin/one/devos/yiski/runner/Routing.kt b/src/main/kotlin/one/devos/yiski/runner/Routing.kt new file mode 100644 index 0000000..c761a37 --- /dev/null +++ b/src/main/kotlin/one/devos/yiski/runner/Routing.kt @@ -0,0 +1,13 @@ +package one.devos.yiski.runner + +import io.ktor.server.application.* +import io.ktor.server.response.* +import io.ktor.server.routing.* + +fun Application.configureRouting() { + routing { + get("/") { + call.respondText("hai hai?!?1 i guess you found me, oh s-siwwy you?!?1 w-weww don't mind me, im just a bot... existing... bweathing... sighing. teww the *boops your nose* devs *starts twerking* i said hai?!?1 :3") + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/one/devos/yiski/runner/YiskiRunner.kt b/src/main/kotlin/one/devos/yiski/runner/YiskiRunner.kt index 76f3cb1..aadc059 100644 --- a/src/main/kotlin/one/devos/yiski/runner/YiskiRunner.kt +++ b/src/main/kotlin/one/devos/yiski/runner/YiskiRunner.kt @@ -1,5 +1,8 @@ package one.devos.yiski.runner +import io.ktor.server.application.* +import io.ktor.server.cio.* +import io.ktor.server.engine.* import one.devos.yiski.common.YiskiShared import one.devos.yiski.module.loader.impl.ModuleClassLoader import one.devos.yiski.module.loader.impl.ModuleLoader @@ -14,6 +17,9 @@ object YiskiRunner { YiskiShared.initializeModuleLoader(ModuleLoader(classLoader)) bootstrap(classLoader) + + embeddedServer(CIO, port = 39480, host = "0.0.0.0", module = Application::module) + .start(wait = true) } private fun bootstrap(classLoader: ClassLoader) { @@ -21,5 +27,8 @@ object YiskiRunner { val instance = clz.getDeclaredField("INSTANCE").get(null) clz.getDeclaredMethod("start").invoke(instance) } - } + +fun Application.module() { + configureRouting() +} \ No newline at end of file