Update dependency io.javalin:javalin to v6 (#1152)

* Update dependency io.javalin:javalin to v6

* Simple compile fixes

* Simple compile fixes pass 2

* Add results to futures

* Setup jetty server and api routes

* Setup Cors

* Setup basic auth

* Documentation stubs

* Replace chapter mutex cache

* Fix compile

* Disable Jetty Logging

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Syer10 <syer10@users.noreply.github.com>
This commit is contained in:
renovate[bot]
2024-11-17 15:00:53 -05:00
committed by GitHub
parent ba1c2845b6
commit 9cd8cb3d54
31 changed files with 478 additions and 363 deletions

View File

@@ -7,7 +7,7 @@ package suwayomi.tachidesk.manga.controller
* 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 io.javalin.http.HttpCode
import io.javalin.http.HttpStatus
import kotlinx.serialization.json.Json
import suwayomi.tachidesk.manga.impl.CategoryManga
import suwayomi.tachidesk.manga.impl.Chapter
@@ -41,15 +41,15 @@ object MangaController {
}
},
behaviorOf = { ctx, mangaId, onlineFetch ->
ctx.future(
ctx.future {
future {
Manga.getManga(mangaId, onlineFetch)
},
)
}.thenApply { ctx.json(it) }
}
},
withResults = {
json<MangaDataClass>(HttpCode.OK)
httpCode(HttpCode.NOT_FOUND)
json<MangaDataClass>(HttpStatus.OK)
httpCode(HttpStatus.NOT_FOUND)
},
)
@@ -65,15 +65,15 @@ object MangaController {
}
},
behaviorOf = { ctx, mangaId, onlineFetch ->
ctx.future(
ctx.future {
future {
Manga.getMangaFull(mangaId, onlineFetch)
},
)
}.thenApply { ctx.json(it) }
}
},
withResults = {
json<MangaDataClass>(HttpCode.OK)
httpCode(HttpCode.NOT_FOUND)
json<MangaDataClass>(HttpStatus.OK)
httpCode(HttpStatus.NOT_FOUND)
},
)
@@ -88,19 +88,19 @@ object MangaController {
}
},
behaviorOf = { ctx, mangaId ->
ctx.future(
ctx.future {
future { Manga.getMangaThumbnail(mangaId) }
.thenApply {
ctx.header("content-type", it.second)
val httpCacheSeconds = 1.days.inWholeSeconds
ctx.header("cache-control", "max-age=$httpCacheSeconds")
it.first
},
)
ctx.result(it.first)
}
}
},
withResults = {
image(HttpCode.OK)
httpCode(HttpCode.NOT_FOUND)
image(HttpStatus.OK)
httpCode(HttpStatus.NOT_FOUND)
},
)
@@ -115,13 +115,14 @@ object MangaController {
}
},
behaviorOf = { ctx, mangaId ->
ctx.future(
future { Library.addMangaToLibrary(mangaId) },
)
ctx.future {
future { Library.addMangaToLibrary(mangaId) }
.thenApply { ctx.status(HttpStatus.OK) }
}
},
withResults = {
httpCode(HttpCode.OK)
httpCode(HttpCode.NOT_FOUND)
httpCode(HttpStatus.OK)
httpCode(HttpStatus.NOT_FOUND)
},
)
@@ -136,13 +137,14 @@ object MangaController {
}
},
behaviorOf = { ctx, mangaId ->
ctx.future(
future { Library.removeMangaFromLibrary(mangaId) },
)
ctx.future {
future { Library.removeMangaFromLibrary(mangaId) }
.thenApply { ctx.status(HttpStatus.OK) }
}
},
withResults = {
httpCode(HttpCode.OK)
httpCode(HttpCode.NOT_FOUND)
httpCode(HttpStatus.OK)
httpCode(HttpStatus.NOT_FOUND)
},
)
@@ -160,7 +162,7 @@ object MangaController {
ctx.json(CategoryManga.getMangaCategories(mangaId))
},
withResults = {
json<Array<CategoryDataClass>>(HttpCode.OK)
json<Array<CategoryDataClass>>(HttpStatus.OK)
},
)
@@ -180,7 +182,7 @@ object MangaController {
ctx.status(200)
},
withResults = {
httpCode(HttpCode.OK)
httpCode(HttpStatus.OK)
},
)
@@ -200,7 +202,7 @@ object MangaController {
ctx.status(200)
},
withResults = {
httpCode(HttpCode.OK)
httpCode(HttpStatus.OK)
},
)
@@ -221,8 +223,8 @@ object MangaController {
ctx.status(200)
},
withResults = {
httpCode(HttpCode.OK)
httpCode(HttpCode.NOT_FOUND)
httpCode(HttpStatus.OK)
httpCode(HttpStatus.NOT_FOUND)
},
)
@@ -242,11 +244,14 @@ object MangaController {
}
},
behaviorOf = { ctx, mangaId, onlineFetch ->
ctx.future(future { Chapter.getChapterList(mangaId, onlineFetch) })
ctx.future {
future { Chapter.getChapterList(mangaId, onlineFetch) }
.thenApply { ctx.json(it) }
}
},
withResults = {
json<Array<ChapterDataClass>>(HttpCode.OK)
httpCode(HttpCode.NOT_FOUND)
json<Array<ChapterDataClass>>(HttpStatus.OK)
httpCode(HttpStatus.NOT_FOUND)
},
)
@@ -266,7 +271,7 @@ object MangaController {
Chapter.modifyChapters(input, mangaId)
},
withResults = {
httpCode(HttpCode.OK)
httpCode(HttpStatus.OK)
},
)
@@ -291,7 +296,7 @@ object MangaController {
)
},
withResults = {
httpCode(HttpCode.OK)
httpCode(HttpStatus.OK)
},
)
@@ -307,11 +312,14 @@ object MangaController {
}
},
behaviorOf = { ctx, mangaId, chapterIndex ->
ctx.future(future { getChapterDownloadReadyByIndex(chapterIndex, mangaId) })
ctx.future {
future { getChapterDownloadReadyByIndex(chapterIndex, mangaId) }
.thenApply { ctx.json(it) }
}
},
withResults = {
json<ChapterDataClass>(HttpCode.OK)
httpCode(HttpCode.NOT_FOUND)
json<ChapterDataClass>(HttpStatus.OK)
httpCode(HttpStatus.NOT_FOUND)
},
)
@@ -336,7 +344,7 @@ object MangaController {
ctx.status(200)
},
withResults = {
httpCode(HttpCode.OK)
httpCode(HttpStatus.OK)
},
)
@@ -357,8 +365,8 @@ object MangaController {
ctx.status(200)
},
withResults = {
httpCode(HttpCode.OK)
httpCode(HttpCode.NOT_FOUND)
httpCode(HttpStatus.OK)
httpCode(HttpStatus.NOT_FOUND)
},
)
@@ -381,8 +389,8 @@ object MangaController {
ctx.status(200)
},
withResults = {
httpCode(HttpCode.OK)
httpCode(HttpCode.NOT_FOUND)
httpCode(HttpStatus.OK)
httpCode(HttpStatus.NOT_FOUND)
},
)
@@ -401,19 +409,19 @@ object MangaController {
}
},
behaviorOf = { ctx, mangaId, chapterIndex, index ->
ctx.future(
ctx.future {
future { Page.getPageImage(mangaId, chapterIndex, index) }
.thenApply {
ctx.header("content-type", it.second)
val httpCacheSeconds = 1.days.inWholeSeconds
ctx.header("cache-control", "max-age=$httpCacheSeconds")
it.first
},
)
ctx.result(it.first)
}
}
},
withResults = {
image(HttpCode.OK)
httpCode(HttpCode.NOT_FOUND)
image(HttpStatus.OK)
httpCode(HttpStatus.NOT_FOUND)
},
)
}