From 41a3ee9710c8df2d7e56deca6ad048778b2d2e06 Mon Sep 17 00:00:00 2001 From: Kolby Moroz Liebl <31669092+KolbyML@users.noreply.github.com> Date: Thu, 29 Apr 2021 18:49:45 -0600 Subject: [PATCH] Add version api endpoint --- server/build.gradle.kts | 8 ++++++++ server/src/main/kotlin/ir/armor/tachidesk/impl/Version.kt | 6 ++++++ .../main/kotlin/ir/armor/tachidesk/server/JavalinSetup.kt | 6 ++++++ 3 files changed, 20 insertions(+) create mode 100644 server/src/main/kotlin/ir/armor/tachidesk/impl/Version.kt diff --git a/server/build.gradle.kts b/server/build.gradle.kts index 2b19fcf09..6d9b169b6 100644 --- a/server/build.gradle.kts +++ b/server/build.gradle.kts @@ -7,8 +7,10 @@ plugins { id("com.github.johnrengelman.shadow") version "6.1.0" id("org.jmailen.kotlinter") version "3.3.0" id("edu.sc.seis.launch4j") version "2.4.9" + id("de.fuerstenau.buildconfig") version "1.1.8" } +val group = "ir.armor.tachidesk" val TachideskVersion = "v0.3.0" @@ -215,5 +217,11 @@ tasks.named("processResources") { mustRunAfter(":webUI:copyBuild") } +buildConfig { + version = TachideskVersion + clsName = "BuildConfig" + packageName = group.toString() + buildConfigField("boolean", "DEBUG", project.hasProperty("debugApp").toString()) +} diff --git a/server/src/main/kotlin/ir/armor/tachidesk/impl/Version.kt b/server/src/main/kotlin/ir/armor/tachidesk/impl/Version.kt new file mode 100644 index 000000000..c5d96c25a --- /dev/null +++ b/server/src/main/kotlin/ir/armor/tachidesk/impl/Version.kt @@ -0,0 +1,6 @@ +package ir.armor.tachidesk.impl +import ir.armor.tachidesk.BuildConfig + +fun getVersion(): String { + return BuildConfig.VERSION +} diff --git a/server/src/main/kotlin/ir/armor/tachidesk/server/JavalinSetup.kt b/server/src/main/kotlin/ir/armor/tachidesk/server/JavalinSetup.kt index 899c38abf..3aa908bcc 100644 --- a/server/src/main/kotlin/ir/armor/tachidesk/server/JavalinSetup.kt +++ b/server/src/main/kotlin/ir/armor/tachidesk/server/JavalinSetup.kt @@ -33,6 +33,7 @@ import ir.armor.tachidesk.impl.Source.getSourceList import ir.armor.tachidesk.impl.backup.BackupFlags import ir.armor.tachidesk.impl.backup.legacy.LegacyBackupExport.createLegacyBackup import ir.armor.tachidesk.impl.backup.legacy.LegacyBackupImport.restoreLegacyBackup +import ir.armor.tachidesk.impl.getVersion import ir.armor.tachidesk.server.util.openInBrowser import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -297,6 +298,11 @@ object JavalinSetup { ctx.status(200) } + // returns version of the app + app.get("/api/v1/version/") { ctx -> + ctx.json(getVersion()) + } + // category modification app.patch("/api/v1/category/:categoryId") { ctx -> val categoryId = ctx.pathParam("categoryId").toInt()