mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-03 19:04:39 -05:00
separate Global API
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
package suwayomi.tachidesk.global
|
||||||
|
|
||||||
|
import io.javalin.Javalin
|
||||||
|
import suwayomi.tachidesk.global.impl.About
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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/. */
|
||||||
|
|
||||||
|
object GlobalAPI {
|
||||||
|
fun defineEndpoints(app: Javalin) {
|
||||||
|
// returns some static info about the current app build
|
||||||
|
app.get("/api/v1/settings/about/") { ctx ->
|
||||||
|
ctx.json(About.getAbout())
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: app update check api
|
||||||
|
app.get("/api/v1/settings/check-update/") { ctx ->
|
||||||
|
ctx.json(About.getAbout())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package suwayomi.tachidesk.server.impl
|
package suwayomi.tachidesk.global.impl
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) Contributors to the Suwayomi project
|
* Copyright (C) Contributors to the Suwayomi project
|
||||||
@@ -43,7 +43,6 @@ import suwayomi.tachidesk.manga.impl.extension.Extension.uninstallExtension
|
|||||||
import suwayomi.tachidesk.manga.impl.extension.Extension.updateExtension
|
import suwayomi.tachidesk.manga.impl.extension.Extension.updateExtension
|
||||||
import suwayomi.tachidesk.manga.impl.extension.ExtensionsList.getExtensionList
|
import suwayomi.tachidesk.manga.impl.extension.ExtensionsList.getExtensionList
|
||||||
import suwayomi.tachidesk.server.JavalinSetup.future
|
import suwayomi.tachidesk.server.JavalinSetup.future
|
||||||
import suwayomi.tachidesk.server.impl.About
|
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
@@ -89,7 +88,7 @@ object MangaAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// icon for extension named `apkName`
|
// icon for extension named `apkName`
|
||||||
app.get("/api/v1/extension/icon/:apkName") { ctx -> // TODO: move to pkgName
|
app.get("/api/v1/extension/icon/:apkName") { ctx ->
|
||||||
val apkName = ctx.pathParam("apkName")
|
val apkName = ctx.pathParam("apkName")
|
||||||
|
|
||||||
ctx.result(
|
ctx.result(
|
||||||
@@ -330,11 +329,6 @@ object MangaAPI {
|
|||||||
ctx.status(200)
|
ctx.status(200)
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns some static info of the current app build
|
|
||||||
app.get("/api/v1/about/") { ctx ->
|
|
||||||
ctx.json(About.getAbout())
|
|
||||||
}
|
|
||||||
|
|
||||||
// category modification
|
// category modification
|
||||||
app.patch("/api/v1/category/:categoryId") { ctx ->
|
app.patch("/api/v1/category/:categoryId") { ctx ->
|
||||||
val categoryId = ctx.pathParam("categoryId").toInt()
|
val categoryId = ctx.pathParam("categoryId").toInt()
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ object Source {
|
|||||||
sourceId.toString(),
|
sourceId.toString(),
|
||||||
source?.get(SourceTable.name),
|
source?.get(SourceTable.name),
|
||||||
source?.get(SourceTable.lang),
|
source?.get(SourceTable.lang),
|
||||||
source?.let { ExtensionTable.select { ExtensionTable.id eq source[SourceTable.extension] }.first()[ExtensionTable.iconUrl] },
|
source?.let { getExtensionIconUrl(ExtensionTable.select { ExtensionTable.id eq source[SourceTable.extension] }.first()[ExtensionTable.apkName]) },
|
||||||
source?.let { getHttpSource(sourceId).supportsLatest },
|
source?.let { getHttpSource(sourceId).supportsLatest },
|
||||||
source?.let { getHttpSource(sourceId) is ConfigurableSource },
|
source?.let { getHttpSource(sourceId) is ConfigurableSource },
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import kotlinx.coroutines.SupervisorJob
|
|||||||
import kotlinx.coroutines.future.future
|
import kotlinx.coroutines.future.future
|
||||||
import mu.KotlinLogging
|
import mu.KotlinLogging
|
||||||
import suwayomi.tachidesk.anime.AnimeAPI
|
import suwayomi.tachidesk.anime.AnimeAPI
|
||||||
|
import suwayomi.tachidesk.global.GlobalAPI
|
||||||
import suwayomi.tachidesk.manga.MangaAPI
|
import suwayomi.tachidesk.manga.MangaAPI
|
||||||
import suwayomi.tachidesk.server.util.Browser
|
import suwayomi.tachidesk.server.util.Browser
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
@@ -75,6 +76,7 @@ object JavalinSetup {
|
|||||||
ctx.result(e.message ?: "Internal Server Error")
|
ctx.result(e.message ?: "Internal Server Error")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GlobalAPI.defineEndpoints(app)
|
||||||
MangaAPI.defineEndpoints(app)
|
MangaAPI.defineEndpoints(app)
|
||||||
AnimeAPI.defineEndpoints(app)
|
AnimeAPI.defineEndpoints(app)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import io.javalin.plugin.json.JavalinJackson
|
|||||||
import mu.KotlinLogging
|
import mu.KotlinLogging
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request.Builder
|
import okhttp3.Request.Builder
|
||||||
import suwayomi.tachidesk.server.impl.AboutDataClass
|
import suwayomi.tachidesk.global.impl.AboutDataClass
|
||||||
import suwayomi.tachidesk.server.serverConfig
|
import suwayomi.tachidesk.server.serverConfig
|
||||||
import suwayomi.tachidesk.server.util.Browser.openInBrowser
|
import suwayomi.tachidesk.server.util.Browser.openInBrowser
|
||||||
import suwayomi.tachidesk.server.util.ExitCode.MutexCheckFailedAnotherAppRunning
|
import suwayomi.tachidesk.server.util.ExitCode.MutexCheckFailedAnotherAppRunning
|
||||||
|
|||||||
Reference in New Issue
Block a user