Rework the version endpoint

This commit is contained in:
Aria Moradi 2021-04-30 06:07:29 +04:30
parent 34d8feacdd
commit bf6a0aba5d
4 changed files with 31 additions and 13 deletions

View File

@ -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())
}

View File

@ -1,6 +0,0 @@
package ir.armor.tachidesk.impl
import ir.armor.tachidesk.BuildConfig
fun getVersion(): String {
return BuildConfig.VERSION
}

View File

@ -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

View File

@ -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,
)
}
}