diff options
author | Linnea Gräf <nea@nea.moe> | 2025-01-17 16:15:56 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2025-01-17 16:15:56 +0100 |
commit | d391ce632be29c49a612c64eb5f720238a46844d (patch) | |
tree | a0a8b92c9ec550a5c794fc6edaf9fd71e1621490 /server/core | |
parent | aa7e28e799ce19f04c6c33782ea8d25ef4c3bb98 (diff) | |
download | LocalTransactionLedger-d391ce632be29c49a612c64eb5f720238a46844d.tar.gz LocalTransactionLedger-d391ce632be29c49a612c64eb5f720238a46844d.tar.bz2 LocalTransactionLedger-d391ce632be29c49a612c64eb5f720238a46844d.zip |
feat(server): Add all in one http server
Diffstat (limited to 'server/core')
-rw-r--r-- | server/core/build.gradle.kts | 18 | ||||
-rw-r--r-- | server/core/src/main/kotlin/moe/nea/ledger/server/core/Application.kt | 14 |
2 files changed, 22 insertions, 10 deletions
diff --git a/server/core/build.gradle.kts b/server/core/build.gradle.kts index ad6c80e..6300a4b 100644 --- a/server/core/build.gradle.kts +++ b/server/core/build.gradle.kts @@ -8,15 +8,15 @@ plugins { dependencies { declareKtorVersion() - implementation("io.ktor:ktor-server-netty") - implementation("io.ktor:ktor-server-status-pages") - implementation("io.ktor:ktor-server-content-negotiation") - implementation("io.ktor:ktor-serialization-kotlinx-json") - implementation("io.ktor:ktor-server-compression") - implementation("io.ktor:ktor-server-cors") - implementation("sh.ondr:kotlin-json-schema:0.1.1") - implementation(project(":database:impl")) - implementation(project(":server:swagger")) + api("io.ktor:ktor-server-netty") + api("io.ktor:ktor-server-status-pages") + api("io.ktor:ktor-server-content-negotiation") + api("io.ktor:ktor-serialization-kotlinx-json") + api("io.ktor:ktor-server-compression") + api("io.ktor:ktor-server-cors") + api("sh.ondr:kotlin-json-schema:0.1.1") + api(project(":database:impl")) + api(project(":server:swagger")) runtimeOnly("ch.qos.logback:logback-classic:1.5.16") runtimeOnly("org.xerial:sqlite-jdbc:3.45.3.0") diff --git a/server/core/src/main/kotlin/moe/nea/ledger/server/core/Application.kt b/server/core/src/main/kotlin/moe/nea/ledger/server/core/Application.kt index a177b05..23b2a6a 100644 --- a/server/core/src/main/kotlin/moe/nea/ledger/server/core/Application.kt +++ b/server/core/src/main/kotlin/moe/nea/ledger/server/core/Application.kt @@ -8,6 +8,7 @@ import io.ktor.server.plugins.compression.Compression import io.ktor.server.plugins.contentnegotiation.ContentNegotiation import io.ktor.server.plugins.cors.routing.CORS import io.ktor.server.response.respondRedirect +import io.ktor.server.routing.Routing import io.ktor.server.routing.get import io.ktor.server.routing.route import io.ktor.server.routing.routing @@ -27,8 +28,17 @@ fun main(args: Array<String>) { EngineMain.main(args) } +interface AIOProvider { + fun Routing.installExtraRouting() + fun Application.module() +} fun Application.module() { + val aio = runCatching { + Class.forName("moe.nea.ledger.server.aio.AIO") + .newInstance() as AIOProvider + }.getOrNull() + aio?.run { module() } install(Compression) install(Documentation) { info = Info( @@ -50,7 +60,8 @@ fun Application.module() { install(CORS) { anyHost() } - val database = Database(File(System.getProperty("ledger.databasefolder"))) + val database = Database(File(System.getProperty("ledger.databasefolder", + "/home/nea/.local/share/PrismLauncher/instances/Skyblock/.minecraft/money-ledger"))) database.loadAndUpgrade() routing { route("/api") { @@ -64,6 +75,7 @@ fun Application.module() { route("/openapi") { openApiUi("/api.json") } + aio?.run { installExtraRouting() } } } |