Skip to content

Commit

Permalink
feat: Move /latest routes to parent
Browse files Browse the repository at this point in the history
There is only ever current releases, so a latest route doesn't make sense.
  • Loading branch information
oSumAtrIX committed Aug 16, 2024
1 parent e113daa commit 4e8e83d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,29 @@ import org.koin.ktor.ext.get as koinGet
internal fun Route.managerRoute() = route("manager") {
val managerService = koinGet<ManagerService>()

route("latest") {
installLatestManagerRouteDocumentation()
installManagerRouteDocumentation()

rateLimit(RateLimitName("weak")) {
get {
call.respond(managerService.latestRelease())
}
rateLimit(RateLimitName("weak")) {
get {
call.respond(managerService.latestRelease())
}

route("version") {
installLatestManagerVersionRouteDocumentation()
route("version") {
installManagerVersionRouteDocumentation()

get {
call.respond(managerService.latestVersion())
}
get {
call.respond(managerService.latestVersion())
}
}
}
}

private fun Route.installLatestManagerRouteDocumentation() = installNotarizedRoute {
private fun Route.installManagerRouteDocumentation() = installNotarizedRoute {
tags = setOf("Manager")

get = GetInfo.builder {
description("Get the latest manager release")
summary("Get latest manager release")
description("Get the current manager release")
summary("Get current manager release")
response {
description("The latest manager release")
mediaTypes("application/json")
Expand All @@ -50,14 +48,14 @@ private fun Route.installLatestManagerRouteDocumentation() = installNotarizedRou
}
}

private fun Route.installLatestManagerVersionRouteDocumentation() = installNotarizedRoute {
private fun Route.installManagerVersionRouteDocumentation() = installNotarizedRoute {
tags = setOf("Manager")

get = GetInfo.builder {
description("Get the latest manager release version")
summary("Get latest manager release version")
description("Get the current manager release version")
summary("Get current manager release version")
response {
description("The latest manager release version")
description("The current manager release version")
mediaTypes("application/json")
responseCode(HttpStatusCode.OK)
responseType<APIReleaseVersion>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,28 @@ import org.koin.ktor.ext.get as koinGet
internal fun Route.patchesRoute() = route("patches") {
val patchesService = koinGet<PatchesService>()

route("latest") {
installLatestPatchesRouteDocumentation()
installPatchesRouteDocumentation()

rateLimit(RateLimitName("weak")) {
get {
call.respond(patchesService.latestRelease())
}
rateLimit(RateLimitName("weak")) {
get {
call.respond(patchesService.latestRelease())
}

route("version") {
installLatestPatchesVersionRouteDocumentation()
route("version") {
installPatchesVersionRouteDocumentation()

get {
call.respond(patchesService.latestVersion())
}
get {
call.respond(patchesService.latestVersion())
}
}
}

rateLimit(RateLimitName("strong")) {
route("list") {
installLatestPatchesListRouteDocumentation()
rateLimit(RateLimitName("strong")) {
route("list") {
installPatchesListRouteDocumentation()

get {
call.respondBytes(ContentType.Application.Json) { patchesService.list() }
}
get {
call.respondBytes(ContentType.Application.Json) { patchesService.list() }
}
}
}
Expand All @@ -60,42 +58,42 @@ internal fun Route.patchesRoute() = route("patches") {
}
}

private fun Route.installLatestPatchesRouteDocumentation() = installNotarizedRoute {
private fun Route.installPatchesRouteDocumentation() = installNotarizedRoute {
tags = setOf("Patches")

get = GetInfo.builder {
description("Get the latest patches release")
summary("Get latest patches release")
description("Get the current patches release")
summary("Get current patches release")
response {
description("The latest patches release")
description("The current patches release")
mediaTypes("application/json")
responseCode(HttpStatusCode.OK)
responseType<APIRelease<APIPatchesAsset>>()
}
}
}

private fun Route.installLatestPatchesVersionRouteDocumentation() = installNotarizedRoute {
private fun Route.installPatchesVersionRouteDocumentation() = installNotarizedRoute {
tags = setOf("Patches")

get = GetInfo.builder {
description("Get the latest patches release version")
summary("Get latest patches release version")
description("Get the current patches release version")
summary("Get current patches release version")
response {
description("The latest patches release version")
description("The current patches release version")
mediaTypes("application/json")
responseCode(HttpStatusCode.OK)
responseType<APIReleaseVersion>()
}
}
}

private fun Route.installLatestPatchesListRouteDocumentation() = installNotarizedRoute {
private fun Route.installPatchesListRouteDocumentation() = installNotarizedRoute {
tags = setOf("Patches")

get = GetInfo.builder {
description("Get the list of patches from the latest patches release")
summary("Get list of patches from latest patches release")
description("Get the list of patches from the current patches release")
summary("Get list of patches from current patches release")
response {
description("The list of patches")
mediaTypes("application/json")
Expand Down

0 comments on commit 4e8e83d

Please sign in to comment.