Pagination on the list, optional auth

This commit is contained in:
2024-07-22 16:19:01 +02:00
parent 7ee04b0a4b
commit 5251c43a6b
11 changed files with 499 additions and 119 deletions
+11 -3
View File
@@ -10,7 +10,7 @@ SimpleRouter::error(function (Request $request, Exception $exception) {
});
// Index
SimpleRouter::all("/", function () {
redirect("docs", 301);
Response::redirect("docs", 301);
});
/*
@@ -18,15 +18,23 @@ SimpleRouter::all("/", function () {
*/
// Login
SimpleRouter::post("/login", [Api\Login\Login::class, "post"]);
// Register and confirm
SimpleRouter::post("/register", [Api\Register\Register::class, "post"]);
SimpleRouter::patch("/register", [Api\Register\Register::class, "patch"]);
/*
* Optional Auth
*/
SimpleRouter::group(["middleware" => Khofmann\Auth\OptAuth::class], function () {
// List posts with user data
SimpleRouter::get("/posts", [Api\Posts\Posts::class, "get"]);
});
/*
* Normal Auth routes
*/
SimpleRouter::group(["middleware" => Khofmann\Auth\Auth::class], function () {
// Login
// Logout
SimpleRouter::post("/logout", [Api\Logout\Logout::class, "post"]);
// Get any user
// Get user
SimpleRouter::get("/user/{id}", [Api\User\User::class, "get"]);
// Update self
SimpleRouter::patch("/user/self", [Api\User\User::class, "patchSelf"]);