From bf6a0aba5de50155b585b4b495f2455f2cf5f8f5 Mon Sep 17 00:00:00 2001 From: Aria Moradi Date: Fri, 30 Apr 2021 06:07:29 +0430 Subject: [PATCH] Rework the version endpoint --- server/build.gradle.kts | 6 ++--- .../kotlin/ir/armor/tachidesk/impl/Version.kt | 6 ----- .../ir/armor/tachidesk/server/JavalinSetup.kt | 8 +++---- .../armor/tachidesk/server/internal/About.kt | 24 +++++++++++++++++++ 4 files changed, 31 insertions(+), 13 deletions(-) delete mode 100644 server/src/main/kotlin/ir/armor/tachidesk/impl/Version.kt create mode 100644 server/src/main/kotlin/ir/armor/tachidesk/server/internal/About.kt diff --git a/server/build.gradle.kts b/server/build.gradle.kts index 6d9b169..67ecfb8 100644 --- a/server/build.gradle.kts +++ b/server/build.gradle.kts @@ -10,10 +10,8 @@ plugins { id("de.fuerstenau.buildconfig") version "1.1.8" } -val group = "ir.armor.tachidesk" val TachideskVersion = "v0.3.0" - repositories { mavenCentral() jcenter() @@ -219,9 +217,11 @@ tasks.named("processResources") { buildConfig { version = TachideskVersion + buildConfigField("String", "version", TachideskVersion) + buildConfigField("String", "revision", TachideskRevision) clsName = "BuildConfig" - packageName = group.toString() + packageName = "ir.armor.tachidesk.server" 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 deleted file mode 100644 index c5d96c2..0000000 --- a/server/src/main/kotlin/ir/armor/tachidesk/impl/Version.kt +++ /dev/null @@ -1,6 +0,0 @@ -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 3aa908b..511801c 100644 --- a/server/src/main/kotlin/ir/armor/tachidesk/server/JavalinSetup.kt +++ b/server/src/main/kotlin/ir/armor/tachidesk/server/JavalinSetup.kt @@ -33,7 +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.internal.About.getAbout import ir.armor.tachidesk.server.util.openInBrowser import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -298,9 +298,9 @@ object JavalinSetup { ctx.status(200) } - // returns version of the app - app.get("/api/v1/version/") { ctx -> - ctx.json(getVersion()) + // returns some static info of the current app build + app.get("/api/v1/about/") { ctx -> + ctx.json(getAbout()) } // category modification diff --git a/server/src/main/kotlin/ir/armor/tachidesk/server/internal/About.kt b/server/src/main/kotlin/ir/armor/tachidesk/server/internal/About.kt new file mode 100644 index 0000000..a99cc2a --- /dev/null +++ b/server/src/main/kotlin/ir/armor/tachidesk/server/internal/About.kt @@ -0,0 +1,24 @@ +package ir.armor.tachidesk.server.internal + +/* + * Copyright (C) Contributors to the Suwayomi project + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +import ir.armor.tachidesk.server.BuildConfig + +data class AboutDataClass( + val version: String, + val revision: String, +) + +object About { + fun getAbout(): AboutDataClass { + return AboutDataClass( + BuildConfig.version, + BuildConfig.revision, + ) + } +}