correct routes
This commit is contained in:
parent
e0e35eb97c
commit
ddd7bb6ba3
|
@ -6,9 +6,10 @@ import dev.frogmc.meta.plugins.configureSerialization
|
|||
import io.ktor.server.application.*
|
||||
import io.ktor.server.engine.*
|
||||
import io.ktor.server.netty.*
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
val logger = LoggerFactory.getLogger("FrogMC/Meta")
|
||||
val logger: Logger = LoggerFactory.getLogger("FrogMC/Meta")
|
||||
|
||||
fun main() {
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package dev.frogmc.meta.plugins
|
||||
|
||||
import dev.frogmc.meta.Config
|
||||
import dev.frogmc.meta.logger
|
||||
import io.ktor.http.*
|
||||
import io.ktor.server.application.*
|
||||
import io.ktor.server.response.*
|
||||
|
@ -15,11 +14,6 @@ val authPlugin = createRouteScopedPlugin("auth") {
|
|||
Config.UPLOAD_SECRET.toByteArray()
|
||||
)
|
||||
) {
|
||||
logger.info(
|
||||
"Authentication Failed: provided: ${
|
||||
authorization
|
||||
}; expected: ${Config.UPLOAD_SECRET}"
|
||||
)
|
||||
it.respond(HttpStatusCode.Unauthorized)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ fun Application.configureRouting() {
|
|||
call.respond(transaction(DB.db) {
|
||||
LoaderVersions
|
||||
.select(LoaderVersions.version, LoaderVersions.releaseDate)
|
||||
.orderBy(LoaderVersions.releaseDate to SortOrder.ASC)
|
||||
.orderBy(LoaderVersions.releaseDate to SortOrder.DESC)
|
||||
.map {
|
||||
PartialLoaderVersion(
|
||||
it[LoaderVersions.version],
|
||||
|
@ -38,7 +38,7 @@ fun Application.configureRouting() {
|
|||
}
|
||||
})
|
||||
}
|
||||
get("/versions/latest") {
|
||||
get("/version/latest") {
|
||||
val row = transaction(DB.db) {
|
||||
LoaderVersions
|
||||
.selectAll()
|
||||
|
@ -59,7 +59,7 @@ fun Application.configureRouting() {
|
|||
)
|
||||
)
|
||||
}
|
||||
get("/versions/{version}") {
|
||||
get("/version/{version}") {
|
||||
val version = call.parameters["version"] ?: return@get call.respond(HttpStatusCode.BadRequest)
|
||||
val row = transaction {
|
||||
LoaderVersions
|
||||
|
@ -81,7 +81,7 @@ fun Application.configureRouting() {
|
|||
)
|
||||
)
|
||||
}
|
||||
route("/versions/upload") {
|
||||
route("/version/upload") {
|
||||
install(authPlugin)
|
||||
post {
|
||||
val versionObj = call.receive<LoaderVersion>()
|
||||
|
@ -101,7 +101,7 @@ fun Application.configureRouting() {
|
|||
call.respond(HttpStatusCode.OK)
|
||||
}
|
||||
}
|
||||
route("/versions/delete/{version}") {
|
||||
route("/version/delete/{version}") {
|
||||
install(authPlugin)
|
||||
delete {
|
||||
val version =
|
||||
|
@ -124,11 +124,11 @@ fun Application.configureRouting() {
|
|||
val versions = DB.getLibraryVersions()
|
||||
call.respond(versions)
|
||||
}
|
||||
get("/versions/latest") {
|
||||
get("/version/latest") {
|
||||
val versions = DB.getLibraryVersions()
|
||||
call.respond(versions.first())
|
||||
}
|
||||
get("/versions/{version}/download") {
|
||||
get("/version/{version}/download") {
|
||||
val version = call.parameters["version"] ?: return@get call.respond(
|
||||
HttpStatusCode.BadRequest,
|
||||
"message" to "Invalid version."
|
||||
|
@ -150,7 +150,7 @@ fun Application.configureRouting() {
|
|||
val mrVersion = json.decodeFromString<ModrinthVersion>(mrVersionString)
|
||||
call.respond(mrVersion.files[0])
|
||||
}
|
||||
get("/versions/{version}") {
|
||||
get("/version/{version}") {
|
||||
val version = call.parameters["version"] ?: return@get call.respond(
|
||||
HttpStatusCode.BadRequest,
|
||||
"message" to "Invalid version."
|
||||
|
|
|
@ -18,28 +18,28 @@
|
|||
</div>
|
||||
<br>
|
||||
<div class="route">
|
||||
<code>GET /v1/loader/versions/latest</code>
|
||||
<code>GET /v1/loader/version/latest</code>
|
||||
<p>Fetches the latest version of FrogMC loader.</p>
|
||||
</div>
|
||||
<br>
|
||||
<div class="route">
|
||||
<code>GET /v1/loader/versions/{version}</code>
|
||||
<code>GET /v1/loader/version/{version}</code>
|
||||
<p>Fetches a specific version of FrogMC loader.</p>
|
||||
</div>
|
||||
<br>
|
||||
<div class="route">
|
||||
<code>GET /v1/loader/versions/{version}/download</code>
|
||||
<code>GET /v1/loader/version/{version}/download</code>
|
||||
<p>Fetches the download URL of a specific version of FrogMC loader.</p>
|
||||
</div>
|
||||
<br>
|
||||
<div class="route">
|
||||
<code>POST /v1/loader/versions/upload</code>
|
||||
<code>POST /v1/loader/version/upload</code>
|
||||
<p>Uploads a version of the loader.</p>
|
||||
<p><strong>This endpoint requires authorization.</strong></p>
|
||||
</div>
|
||||
<br>
|
||||
<div class="route">
|
||||
<code>DELETE /v1/loader/versions/delete/{version}</code>
|
||||
<code>DELETE /v1/loader/version/delete/{version}</code>
|
||||
<p>Deletes a version of the loader.</p>
|
||||
<p><strong>This endpoint requires authorization.</strong></p>
|
||||
</div>
|
||||
|
@ -50,17 +50,17 @@
|
|||
</div>
|
||||
<br>
|
||||
<div class="route">
|
||||
<code>GET /v1/library/versions/latest</code>
|
||||
<code>GET /v1/library/version/latest</code>
|
||||
<p>Fetches the latest version of FrogMC library.</p>
|
||||
</div>
|
||||
<br>
|
||||
<div class="route">
|
||||
<code>GET /v1/library/versions/{version}</code>
|
||||
<code>GET /v1/library/version/{version}</code>
|
||||
<p>Fetches a specific version of FrogMC library.</p>
|
||||
</div>
|
||||
<br>
|
||||
<div class="route">
|
||||
<code>GET /v1/library/versions/{version}/download</code>
|
||||
<code>GET /v1/library/version/{version}/download</code>
|
||||
<p>Fetches the download URL of a specific version of FrogMC library.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue