This commit is contained in:
parent
084643aab5
commit
77aa8421d8
@ -1,6 +1,4 @@
|
||||
import dao.DB
|
||||
import dao.ItemView
|
||||
import dao.KeyView
|
||||
import io.javalin.apibuilder.CrudHandler
|
||||
import io.javalin.http.Context
|
||||
|
||||
|
@ -12,6 +12,7 @@ import org.jetbrains.exposed.sql.transactions.transaction
|
||||
enum class ApiRole : Role { PUBLIC, BASIC_AUTHED, API_AUTHED }
|
||||
|
||||
fun main() {
|
||||
val listIdStr = "list-id"
|
||||
var migrationsController = MigrationsController()
|
||||
val app = Javalin.create {
|
||||
it.accessManager { handler, ctx, permittedRoles ->
|
||||
@ -53,19 +54,19 @@ fun main() {
|
||||
}, roles(ApiRole.PUBLIC))
|
||||
|
||||
get("/api/lists/:list-id/items", { ctx ->
|
||||
ListItemsController().getListItems(ctx, ctx.pathParam("list-id"))
|
||||
ListItemsController().getListItems(ctx, ctx.pathParam(listIdStr))
|
||||
}, roles(ApiRole.API_AUTHED))
|
||||
|
||||
post("/api/lists/:list-id/items", { ctx ->
|
||||
ListItemsController().create(ctx.pathParam("list-id"), ctx)
|
||||
ListItemsController().create(ctx.pathParam(listIdStr), ctx)
|
||||
}, roles(ApiRole.API_AUTHED))
|
||||
|
||||
delete("/api/lists/:list-id/items/:item-id", { ctx ->
|
||||
ListItemsController().delete(ctx.pathParam("list-id"), ctx.pathParam("item-id"), ctx)
|
||||
ListItemsController().delete(ctx.pathParam(listIdStr), ctx.pathParam("item-id"), ctx)
|
||||
}, roles(ApiRole.API_AUTHED))
|
||||
|
||||
patch("/api/lists/:list-id/items/:item-id", { ctx ->
|
||||
ListItemsController().update(ctx.pathParam("list-id"), ctx.pathParam("item-id"), ctx)
|
||||
ListItemsController().update(ctx.pathParam(listIdStr), ctx.pathParam("item-id"), ctx)
|
||||
}, roles(ApiRole.API_AUTHED))
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user