mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-09 22:04:34 -05:00
Switch from Kodein to Koin (#1112)
* Switch from Kodein to Koin * Ktlint
This commit is contained in:
@@ -9,20 +9,17 @@ package suwayomi.tachidesk.manga.controller
|
||||
|
||||
import io.javalin.http.HttpCode
|
||||
import io.javalin.websocket.WsConfig
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import org.kodein.di.DI
|
||||
import org.kodein.di.conf.global
|
||||
import org.kodein.di.instance
|
||||
import suwayomi.tachidesk.manga.impl.download.DownloadManager
|
||||
import suwayomi.tachidesk.manga.impl.download.DownloadManager.EnqueueInput
|
||||
import suwayomi.tachidesk.server.JavalinSetup.future
|
||||
import suwayomi.tachidesk.server.util.handler
|
||||
import suwayomi.tachidesk.server.util.pathParam
|
||||
import suwayomi.tachidesk.server.util.withOperation
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
object DownloadController {
|
||||
private val json by DI.global.instance<Json>()
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
/** Download queue stats */
|
||||
fun downloadsWS(ws: WsConfig) {
|
||||
|
||||
@@ -9,9 +9,6 @@ package suwayomi.tachidesk.manga.controller
|
||||
|
||||
import io.javalin.http.HttpCode
|
||||
import kotlinx.serialization.json.Json
|
||||
import org.kodein.di.DI
|
||||
import org.kodein.di.conf.global
|
||||
import org.kodein.di.instance
|
||||
import suwayomi.tachidesk.manga.impl.CategoryManga
|
||||
import suwayomi.tachidesk.manga.impl.Chapter
|
||||
import suwayomi.tachidesk.manga.impl.Library
|
||||
@@ -27,10 +24,11 @@ import suwayomi.tachidesk.server.util.handler
|
||||
import suwayomi.tachidesk.server.util.pathParam
|
||||
import suwayomi.tachidesk.server.util.queryParam
|
||||
import suwayomi.tachidesk.server.util.withOperation
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import kotlin.time.Duration.Companion.days
|
||||
|
||||
object MangaController {
|
||||
private val json by DI.global.instance<Json>()
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
val retrieve =
|
||||
handler(
|
||||
|
||||
@@ -8,11 +8,7 @@ package suwayomi.tachidesk.manga.controller
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import io.javalin.http.HttpCode
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import org.kodein.di.DI
|
||||
import org.kodein.di.conf.global
|
||||
import org.kodein.di.instance
|
||||
import suwayomi.tachidesk.manga.impl.MangaList
|
||||
import suwayomi.tachidesk.manga.impl.Search
|
||||
import suwayomi.tachidesk.manga.impl.Search.FilterChange
|
||||
@@ -26,6 +22,7 @@ import suwayomi.tachidesk.server.util.handler
|
||||
import suwayomi.tachidesk.server.util.pathParam
|
||||
import suwayomi.tachidesk.server.util.queryParam
|
||||
import suwayomi.tachidesk.server.util.withOperation
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
object SourceController {
|
||||
/** list of sources */
|
||||
@@ -167,7 +164,7 @@ object SourceController {
|
||||
},
|
||||
)
|
||||
|
||||
private val json by DI.global.instance<Json>()
|
||||
private val json: Json by injectLazy()
|
||||
|
||||
/** change filters of source with id `sourceId` */
|
||||
val setFilters =
|
||||
|
||||
@@ -10,9 +10,6 @@ package suwayomi.tachidesk.manga.controller
|
||||
import io.javalin.http.HttpCode
|
||||
import kotlinx.serialization.json.Json
|
||||
import mu.KotlinLogging
|
||||
import org.kodein.di.DI
|
||||
import org.kodein.di.conf.global
|
||||
import org.kodein.di.instance
|
||||
import suwayomi.tachidesk.manga.impl.track.Track
|
||||
import suwayomi.tachidesk.manga.model.dataclass.TrackerDataClass
|
||||
import suwayomi.tachidesk.server.JavalinSetup.future
|
||||
@@ -20,10 +17,11 @@ import suwayomi.tachidesk.server.util.handler
|
||||
import suwayomi.tachidesk.server.util.pathParam
|
||||
import suwayomi.tachidesk.server.util.queryParam
|
||||
import suwayomi.tachidesk.server.util.withOperation
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import kotlin.time.Duration.Companion.days
|
||||
|
||||
object TrackController {
|
||||
private val json by DI.global.instance<Json>()
|
||||
private val json: Json by injectLazy()
|
||||
private val logger = KotlinLogging.logger {}
|
||||
|
||||
val list =
|
||||
|
||||
@@ -3,9 +3,6 @@ package suwayomi.tachidesk.manga.controller
|
||||
import io.javalin.http.HttpCode
|
||||
import io.javalin.websocket.WsConfig
|
||||
import mu.KotlinLogging
|
||||
import org.kodein.di.DI
|
||||
import org.kodein.di.conf.global
|
||||
import org.kodein.di.instance
|
||||
import suwayomi.tachidesk.manga.impl.Category
|
||||
import suwayomi.tachidesk.manga.impl.Chapter
|
||||
import suwayomi.tachidesk.manga.impl.update.IUpdater
|
||||
@@ -18,6 +15,8 @@ import suwayomi.tachidesk.server.util.formParam
|
||||
import suwayomi.tachidesk.server.util.handler
|
||||
import suwayomi.tachidesk.server.util.pathParam
|
||||
import suwayomi.tachidesk.server.util.withOperation
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
/*
|
||||
* Copyright (C) Contributors to the Suwayomi project
|
||||
@@ -67,7 +66,7 @@ object UpdateController {
|
||||
}
|
||||
},
|
||||
behaviorOf = { ctx, categoryId ->
|
||||
val updater by DI.global.instance<IUpdater>()
|
||||
val updater = Injekt.get<IUpdater>()
|
||||
if (categoryId == null) {
|
||||
logger.info { "Adding Library to Update Queue" }
|
||||
updater.addCategoriesToUpdateQueue(
|
||||
@@ -116,7 +115,7 @@ object UpdateController {
|
||||
}
|
||||
},
|
||||
behaviorOf = { ctx ->
|
||||
val updater by DI.global.instance<IUpdater>()
|
||||
val updater = Injekt.get<IUpdater>()
|
||||
ctx.json(updater.statusDeprecated.value)
|
||||
},
|
||||
withResults = {
|
||||
@@ -133,7 +132,7 @@ object UpdateController {
|
||||
}
|
||||
},
|
||||
behaviorOf = { ctx ->
|
||||
val updater by DI.global.instance<IUpdater>()
|
||||
val updater = Injekt.get<IUpdater>()
|
||||
logger.info { "Resetting Updater" }
|
||||
ctx.future(
|
||||
future {
|
||||
|
||||
Reference in New Issue
Block a user