Skip to content

Commit

Permalink
Hide admin route in OpenAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziedelth committed Apr 19, 2024
1 parent d790803 commit 214c662
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 41 deletions.
19 changes: 3 additions & 16 deletions src/main/kotlin/fr/shikkanime/controllers/api/AnimeController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,12 @@ class AnimeController : HasPageableRoute() {

@Path("/{uuid}")
@Get
@OpenAPI(
"Get anime details",
[
OpenAPIResponse(
200,
"Anime found",
AnimeDto::class,
),
OpenAPIResponse(
404,
"Anime not found",
MessageDto::class
),
]
)
@AdminSessionAuthenticated
@OpenAPI(hidden = true)
private fun animeDetails(
@PathParam("uuid") uuid: UUID,
): Response {
return Response.ok(animeCacheService.findByUuid(uuid))
return Response.ok(animeService.find(uuid))
}

@Path("/{uuid}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,10 @@ class EpisodeMappingController : HasPageableRoute() {

@Path("/{uuid}")
@Get
@OpenAPI(
"Get episode mapping by UUID",
[
OpenAPIResponse(
200,
"Episode mapping found",
EpisodeMappingDto::class,
),
]
)
@AdminSessionAuthenticated
@OpenAPI(hidden = true)
private fun read(@PathParam("uuid") uuid: UUID): Response {
return Response.ok(episodeMappingCacheService.find(uuid))
return Response.ok(episodeMappingService.find(uuid))
}

@Path("/{uuid}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.google.inject.Inject
import fr.shikkanime.caches.CountryCodeLocalDateKeyCache
import fr.shikkanime.caches.CountryCodeNamePaginationKeyCache
import fr.shikkanime.caches.CountryCodeUUIDSortPaginationKeyCache
import fr.shikkanime.converters.AbstractConverter
import fr.shikkanime.dtos.AnimeDto
import fr.shikkanime.dtos.PageableDto
import fr.shikkanime.dtos.WeeklyAnimesDto
Expand Down Expand Up @@ -59,10 +58,6 @@ class AnimeCacheService : AbstractCacheService {
animeService.getWeeklyAnimes(it.localDate, it.countryCode)
}

private val findByUuidCache = MapCache<UUID, AnimeDto>(classes = listOf(Anime::class.java)) {
AbstractConverter.convert(animeService.find(it), AnimeDto::class.java)
}

fun findAllBy(
countryCode: CountryCode?,
uuid: UUID?,
Expand All @@ -79,6 +74,4 @@ class AnimeCacheService : AbstractCacheService {

fun getWeeklyAnimes(startOfWeekDay: LocalDate, countryCode: CountryCode) =
weeklyCache[CountryCodeLocalDateKeyCache(countryCode, startOfWeekDay)]

fun findByUuid(uuid: UUID) = findByUuidCache[uuid]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package fr.shikkanime.services.caches

import com.google.inject.Inject
import fr.shikkanime.caches.CountryCodeUUIDSortPaginationKeyCache
import fr.shikkanime.converters.AbstractConverter
import fr.shikkanime.dtos.EpisodeMappingDto
import fr.shikkanime.dtos.PageableDto
import fr.shikkanime.dtos.enums.Status
Expand Down Expand Up @@ -42,10 +41,6 @@ class EpisodeMappingCacheService : AbstractCacheService {
)
}

private val findByUuidCache = MapCache<UUID, EpisodeMappingDto>(classes = listOf(EpisodeMapping::class.java)) {
AbstractConverter.convert(episodeMappingService.find(it), EpisodeMappingDto::class.java)
}

fun findAllBy(
countryCode: CountryCode?,
anime: UUID?,
Expand All @@ -54,6 +49,4 @@ class EpisodeMappingCacheService : AbstractCacheService {
limit: Int,
status: Status? = null
) = findAllByCache[CountryCodeUUIDSortPaginationKeyCache(countryCode, anime, sort, page, limit, status)]

fun find(uuid: UUID) = findByUuidCache[uuid]
}

0 comments on commit 214c662

Please sign in to comment.