Skip to content

Commit

Permalink
Merge pull request #123 from Kurozora/fix-route-cahing
Browse files Browse the repository at this point in the history
[Update] Route Names
  • Loading branch information
kiritokatklian authored Apr 28, 2021
2 parents 4d24303 + c286d32 commit 5b9d6a7
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 38 deletions.
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
| or any other location as required by the application or its packages.
*/

'version' => '1.2.0-alpha.28',
'version' => '1.2.0-alpha.29',

/*
|--------------------------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions routes/API/Anime.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
->name('.anime')
->group(function() {
Route::get('/search', [AnimeController::class, 'search'])
->middleware('kurozora.userauth:optional');
->middleware('kurozora.userauth:optional')
->name('.search');

Route::get('/{anime}', [AnimeController::class, 'view'])
->middleware('kurozora.userauth:optional')
Expand Down Expand Up @@ -36,5 +37,6 @@
->name('.studios');

Route::post('/{anime}/rate', [AnimeController::class, 'rateAnime'])
->middleware('kurozora.userauth');
->middleware('kurozora.userauth')
->name('.rate');
});
6 changes: 4 additions & 2 deletions routes/API/Feed/Messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
->name('.details');

Route::get('/{feedMessage}/replies', [FeedMessageController::class, 'replies'])
->middleware('kurozora.userauth:optional');
->middleware('kurozora.userauth:optional')
->name('.replies');

Route::post('/{feedMessage}/heart', [FeedMessageController::class, 'heart'])
->middleware('kurozora.userauth');
->middleware('kurozora.userauth')
->name('.heart');
});
13 changes: 8 additions & 5 deletions routes/API/Forum-Threads.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,26 @@
->name('.forum-threads')
->group(function() {
Route::get('/search', [ForumThreadController::class, 'search'])
->middleware('kurozora.userauth:optional');
->middleware('kurozora.userauth:optional')
->name('.search');

Route::get('/{thread}', [ForumThreadController::class, 'details'])
->middleware('kurozora.userauth:optional')
->name('.details');

Route::post('/{thread}/vote', [ForumThreadController::class, 'vote'])
->middleware('kurozora.userauth');
->middleware('kurozora.userauth')
->name('.vote');

Route::get('/{thread}/replies', [ForumThreadController::class, 'replies'])
->middleware('kurozora.userauth:optional')
->name('.replies');

Route::post('/{thread}/replies', [ForumThreadController::class, 'postReply'])
->middleware('kurozora.userauth');
->middleware('kurozora.userauth')
->name('.reply');

Route::post('/{thread}/lock', [ForumThreadController::class, 'lock'])
->middleware('kurozora.userauth')
->middleware('can:lock_thread,thread');
->middleware(['kurozora.userauth', 'can:lock_thread,thread'])
->name('.lock');
});
9 changes: 6 additions & 3 deletions routes/API/Me.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
->middleware('kurozora.userauth');

Route::post('/', [MeController::class, 'updateProfile'])
->middleware('kurozora.userauth');
->middleware('kurozora.userauth')
->name('.update');

Route::get('/followers', [MeController::class, 'getFollowers'])
->middleware('kurozora.userauth:optional');
->middleware('kurozora.userauth:optional')
->name('.followers');

Route::get('/following', [MeController::class, 'getFollowing'])
->middleware('kurozora.userauth:optional');
->middleware('kurozora.userauth:optional')
->name('.following');

require 'Me/Favorite-Anime.php';
require 'Me/Feed-Messages.php';
Expand Down
3 changes: 2 additions & 1 deletion routes/API/Me/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@
->name('.mal-import');

Route::get('/search', [LibraryController::class, 'search'])
->middleware('kurozora.userauth');
->middleware('kurozora.userauth')
->name('.search');
});
7 changes: 4 additions & 3 deletions routes/API/Me/Notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
->name('.details');

Route::post('/{notification}/delete', [NotificationController::class, 'delete'])
->middleware('kurozora.userauth')
->middleware('can:del_notification,notification');
->middleware(['kurozora.userauth', 'can:del_notification,notification'])
->name('.delete');

Route::post('/update', [NotificationController::class, 'update'])
->middleware('kurozora.userauth');
->middleware('kurozora.userauth')
->name('.update');
});
3 changes: 1 addition & 2 deletions routes/API/Me/Sessions.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
->name('.update');

Route::post('/{session}/delete', [SessionController::class, 'delete'])
->middleware('kurozora.userauth')
->middleware('can:delete_session,session')
->middleware(['kurozora.userauth', 'can:delete_session,session'])
->name('.delete');
});
3 changes: 2 additions & 1 deletion routes/API/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
->name('.details');

Route::post('/verify', [StoreController::class, 'verifyReceipt'])
->middleware('kurozora.userauth:optional');
->middleware('kurozora.userauth:optional')
->name('.verify');
});
29 changes: 18 additions & 11 deletions routes/API/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,40 @@
->group(function() {
Route::post('/', [RegistrationController::class, 'signUp']);

Route::post('/signin', [SessionController::class, 'create']);
Route::post('/signin', [SessionController::class, 'create'])
->name('.sign-in');

Route::post('/signin/siwa', [SignInWithAppleController::class, 'signIn']);
Route::post('/signin/siwa', [SignInWithAppleController::class, 'signIn'])
->name('.sign-in.siwa');

Route::post('/reset-password', [UserController::class, 'resetPassword']);
Route::post('/reset-password', [UserController::class, 'resetPassword'])
->name('.reset-password');

Route::get('/{user}/favorite-anime', [FavoriteAnimeController::class, 'getFavorites'])
->middleware('kurozora.userauth')
->middleware('can:get_anime_favorites,user');
->middleware(['kurozora.userauth', 'can:get_anime_favorites,user'])
->name('.favorite-anime');

Route::get('/{user}/feed-messages', [UserController::class, 'getFeedMessages'])
->middleware('kurozora.userauth:optional');
->middleware('kurozora.userauth:optional')
->name('.feed-messages');

Route::post('/{user}/follow', [FollowingController::class, 'followUser'])
->middleware('kurozora.userauth')
->middleware('can:follow,user');
->middleware(['kurozora.userauth', 'can:follow,user'])
->name('.follow');

Route::get('/{user}/followers', [FollowingController::class, 'getFollowers'])
->middleware('kurozora.userauth:optional');
->middleware('kurozora.userauth:optional')
->name('.followers');

Route::get('/{user}/following', [FollowingController::class, 'getFollowing'])
->middleware('kurozora.userauth:optional');
->middleware('kurozora.userauth:optional')
->name('.following');

Route::get('/{user}/profile', [UserController::class, 'profile'])
->middleware('kurozora.userauth:optional')
->name('.profile');

Route::get('/search', [UserController::class, 'search'])
->middleware('kurozora.userauth:optional');
->middleware('kurozora.userauth:optional')
->name('.search');
});
15 changes: 10 additions & 5 deletions routes/Web/Authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,22 @@
->name('.update');

Route::post('/user/two-factor-authentication', [TwoFactorAuthenticationController::class, 'store'])
->middleware(['auth', 'password.confirm']);
->middleware(['auth', 'password.confirm'])
->name('.two-factor-authentication.store');

Route::delete('/user/two-factor-authentication', [TwoFactorAuthenticationController::class, 'destroy'])
->middleware(['auth', 'password.confirm']);
->middleware(['auth', 'password.confirm'])
->name('.two-factor-authentication.remove');

Route::get('/user/two-factor-qr-code', [TwoFactorQrCodeController::class, 'show'])
->middleware(['auth', 'password.confirm']);
->middleware(['auth', 'password.confirm'])
->name('.two-factor-qr-code');

Route::get('/user/two-factor-recovery-codes', [RecoveryCodeController::class, 'index'])
->middleware(['auth', 'password.confirm']);
->middleware(['auth', 'password.confirm'])
->name('.two-factor-recovery-codes');

Route::post('/user/two-factor-recovery-codes', [RecoveryCodeController::class, 'store'])
->middleware(['auth', 'password.confirm']);
->middleware(['auth', 'password.confirm'])
->name('.two-factor-recovery-codes.store');
});
6 changes: 4 additions & 2 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
->group(function () {
Route::get('/', ApiIndex::class);

Route::get('/info', [APIController::class, 'info']);
Route::get('/info', [APIController::class, 'info'])
->name('.info');

Route::get('/explore', [ExplorePageController::class, 'explore'])
->middleware('kurozora.userauth:optional')
Expand All @@ -33,5 +34,6 @@
require 'API/Themes.php';
require 'API/Users.php';

Route::fallback([APIController::class, 'error']);
Route::fallback([APIController::class, 'error'])
->name('.fallback');
});

0 comments on commit 5b9d6a7

Please sign in to comment.