2022-06-10 10:47:46 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use App\Facades\YouTube;
|
2024-01-13 17:57:24 +00:00
|
|
|
use App\Http\Controllers\API\ActivateLicenseController;
|
2023-06-05 21:46:41 +00:00
|
|
|
use App\Http\Controllers\API\AlbumController;
|
|
|
|
use App\Http\Controllers\API\AlbumSongController;
|
|
|
|
use App\Http\Controllers\API\ArtistAlbumController;
|
|
|
|
use App\Http\Controllers\API\ArtistController;
|
|
|
|
use App\Http\Controllers\API\ArtistSongController;
|
2022-06-10 10:47:46 +00:00
|
|
|
use App\Http\Controllers\API\AuthController;
|
2024-01-02 12:07:37 +00:00
|
|
|
use App\Http\Controllers\API\DisconnectFromLastfmController;
|
2023-06-05 21:46:41 +00:00
|
|
|
use App\Http\Controllers\API\ExcerptSearchController;
|
|
|
|
use App\Http\Controllers\API\FetchAlbumInformationController;
|
2024-01-02 12:07:37 +00:00
|
|
|
use App\Http\Controllers\API\FetchAlbumThumbnailController;
|
2023-06-05 21:46:41 +00:00
|
|
|
use App\Http\Controllers\API\FetchArtistInformationController;
|
2024-02-28 04:37:27 +00:00
|
|
|
use App\Http\Controllers\API\FetchDemoCreditsController;
|
2024-01-02 12:07:37 +00:00
|
|
|
use App\Http\Controllers\API\FetchFavoriteSongsController;
|
|
|
|
use App\Http\Controllers\API\FetchInitialDataController;
|
|
|
|
use App\Http\Controllers\API\FetchOverviewController;
|
2023-06-05 21:46:41 +00:00
|
|
|
use App\Http\Controllers\API\FetchRandomSongsInGenreController;
|
2024-01-02 12:07:37 +00:00
|
|
|
use App\Http\Controllers\API\FetchRecentlyPlayedSongController;
|
|
|
|
use App\Http\Controllers\API\FetchSongsForQueueController;
|
2024-02-25 19:32:53 +00:00
|
|
|
use App\Http\Controllers\API\ForgotPasswordController;
|
2023-06-05 21:46:41 +00:00
|
|
|
use App\Http\Controllers\API\GenreController;
|
|
|
|
use App\Http\Controllers\API\GenreSongController;
|
2024-02-05 22:47:13 +00:00
|
|
|
use App\Http\Controllers\API\LambdaSongController as S3SongController;
|
2024-01-10 21:37:24 +00:00
|
|
|
use App\Http\Controllers\API\LikeMultipleSongsController;
|
2024-01-29 21:58:50 +00:00
|
|
|
use App\Http\Controllers\API\MovePlaylistSongsController;
|
2024-01-24 22:39:47 +00:00
|
|
|
use App\Http\Controllers\API\PlaylistCollaboration\AcceptPlaylistCollaborationInviteController;
|
2024-01-18 11:13:05 +00:00
|
|
|
use App\Http\Controllers\API\PlaylistCollaboration\CreatePlaylistCollaborationTokenController;
|
2024-01-24 22:39:47 +00:00
|
|
|
use App\Http\Controllers\API\PlaylistCollaboration\PlaylistCollaboratorController;
|
2022-06-10 10:47:46 +00:00
|
|
|
use App\Http\Controllers\API\PlaylistController;
|
2023-06-05 21:46:41 +00:00
|
|
|
use App\Http\Controllers\API\PlaylistFolderController;
|
|
|
|
use App\Http\Controllers\API\PlaylistFolderPlaylistController;
|
2022-06-10 10:47:46 +00:00
|
|
|
use App\Http\Controllers\API\PlaylistSongController;
|
2024-01-16 21:14:14 +00:00
|
|
|
use App\Http\Controllers\API\PrivatizeSongsController;
|
2022-06-10 10:47:46 +00:00
|
|
|
use App\Http\Controllers\API\ProfileController;
|
2024-01-16 21:14:14 +00:00
|
|
|
use App\Http\Controllers\API\PublicizeSongsController;
|
2024-01-02 12:07:37 +00:00
|
|
|
use App\Http\Controllers\API\QueueStateController;
|
2024-01-10 21:37:24 +00:00
|
|
|
use App\Http\Controllers\API\RegisterPlayController;
|
2024-02-25 19:32:53 +00:00
|
|
|
use App\Http\Controllers\API\ResetPasswordController;
|
2022-06-10 10:47:46 +00:00
|
|
|
use App\Http\Controllers\API\ScrobbleController;
|
2024-01-02 12:07:37 +00:00
|
|
|
use App\Http\Controllers\API\SearchYouTubeController;
|
|
|
|
use App\Http\Controllers\API\SetLastfmSessionKeyController;
|
2022-06-10 10:47:46 +00:00
|
|
|
use App\Http\Controllers\API\SettingController;
|
|
|
|
use App\Http\Controllers\API\SongController;
|
2023-06-05 21:46:41 +00:00
|
|
|
use App\Http\Controllers\API\SongSearchController;
|
2024-01-10 21:37:24 +00:00
|
|
|
use App\Http\Controllers\API\ToggleLikeSongController;
|
|
|
|
use App\Http\Controllers\API\UnlikeMultipleSongsController;
|
2024-01-02 12:07:37 +00:00
|
|
|
use App\Http\Controllers\API\UpdatePlaybackStatusController;
|
2024-01-23 22:50:50 +00:00
|
|
|
use App\Http\Controllers\API\UpdateUserPreferenceController;
|
2024-01-02 12:07:37 +00:00
|
|
|
use App\Http\Controllers\API\UploadAlbumCoverController;
|
|
|
|
use App\Http\Controllers\API\UploadArtistImageController;
|
2022-06-10 10:47:46 +00:00
|
|
|
use App\Http\Controllers\API\UploadController;
|
2024-02-24 15:37:01 +00:00
|
|
|
use App\Http\Controllers\API\UploadPlaylistCoverController;
|
2022-06-10 10:47:46 +00:00
|
|
|
use App\Http\Controllers\API\UserController;
|
2023-08-20 22:35:58 +00:00
|
|
|
use App\Http\Controllers\API\UserInvitationController;
|
2023-06-05 21:46:41 +00:00
|
|
|
use App\Models\Song;
|
2022-06-10 10:47:46 +00:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Support\Facades\Route;
|
|
|
|
use Pusher\Pusher;
|
|
|
|
|
|
|
|
Route::prefix('api')->middleware('api')->group(static function (): void {
|
2024-02-25 19:32:53 +00:00
|
|
|
Route::get('ping', static fn () => null);
|
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
Route::post('me', [AuthController::class, 'login'])->name('auth.login');
|
|
|
|
Route::delete('me', [AuthController::class, 'logout']);
|
|
|
|
|
2024-02-25 19:32:53 +00:00
|
|
|
Route::post('forgot-password', ForgotPasswordController::class);
|
|
|
|
Route::post('reset-password', ResetPasswordController::class);
|
2022-06-10 10:47:46 +00:00
|
|
|
|
2023-08-20 22:35:58 +00:00
|
|
|
Route::get('invitations', [UserInvitationController::class, 'get']);
|
|
|
|
Route::post('invitations/accept', [UserInvitationController::class, 'accept']);
|
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
Route::middleware('auth')->group(static function (): void {
|
|
|
|
Route::post('broadcasting/auth', static function (Request $request) {
|
|
|
|
$pusher = new Pusher(
|
|
|
|
config('broadcasting.connections.pusher.key'),
|
|
|
|
config('broadcasting.connections.pusher.secret'),
|
|
|
|
config('broadcasting.connections.pusher.app_id'),
|
|
|
|
[
|
|
|
|
'cluster' => config('broadcasting.connections.pusher.options.cluster'),
|
|
|
|
'encrypted' => true,
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
return $pusher->socket_auth($request->channel_name, $request->socket_id);
|
|
|
|
})->name('broadcasting.auth');
|
|
|
|
|
2024-01-02 12:07:37 +00:00
|
|
|
Route::get('overview', FetchOverviewController::class);
|
|
|
|
Route::get('data', FetchInitialDataController::class);
|
2022-06-10 10:47:46 +00:00
|
|
|
|
2024-01-02 12:07:37 +00:00
|
|
|
Route::get('queue/fetch', FetchSongsForQueueController::class);
|
|
|
|
Route::put('queue/playback-status', UpdatePlaybackStatusController::class);
|
|
|
|
Route::get('queue/state', [QueueStateController::class, 'show']);
|
|
|
|
Route::put('queue/state', [QueueStateController::class, 'update']);
|
2023-06-05 21:46:41 +00:00
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
Route::put('settings', [SettingController::class, 'update']);
|
|
|
|
|
2023-06-05 21:46:41 +00:00
|
|
|
Route::apiResource('albums', AlbumController::class);
|
|
|
|
Route::apiResource('albums.songs', AlbumSongController::class);
|
|
|
|
|
|
|
|
Route::apiResource('artists', ArtistController::class);
|
|
|
|
Route::apiResource('artists.albums', ArtistAlbumController::class);
|
|
|
|
Route::apiResource('artists.songs', ArtistSongController::class);
|
|
|
|
|
2024-01-02 12:07:37 +00:00
|
|
|
Route::post('songs/{song}/scrobble', ScrobbleController::class)->where(['song' => Song::ID_REGEX]);
|
2023-06-05 21:46:41 +00:00
|
|
|
|
|
|
|
Route::apiResource('songs', SongController::class)
|
|
|
|
->except('update', 'destroy')
|
|
|
|
->where(['song' => Song::ID_REGEX]);
|
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
Route::put('songs', [SongController::class, 'update']);
|
2023-06-05 21:46:41 +00:00
|
|
|
Route::delete('songs', [SongController::class, 'destroy']);
|
2022-06-10 10:47:46 +00:00
|
|
|
|
|
|
|
Route::post('upload', UploadController::class);
|
|
|
|
|
|
|
|
// Interaction routes
|
2024-01-10 21:37:24 +00:00
|
|
|
Route::post('interaction/play', RegisterPlayController::class);
|
2024-01-02 13:10:06 +00:00
|
|
|
Route::post('interaction/like', ToggleLikeSongController::class);
|
2024-01-10 21:37:24 +00:00
|
|
|
Route::post('interaction/batch/like', LikeMultipleSongsController::class);
|
|
|
|
Route::post('interaction/batch/unlike', UnlikeMultipleSongsController::class);
|
2023-06-05 21:46:41 +00:00
|
|
|
|
2024-01-02 12:07:37 +00:00
|
|
|
Route::get('songs/recently-played', FetchRecentlyPlayedSongController::class);
|
|
|
|
Route::get('songs/favorite', FetchFavoriteSongsController::class);
|
2023-06-05 21:46:41 +00:00
|
|
|
|
|
|
|
Route::apiResource('playlist-folders', PlaylistFolderController::class);
|
|
|
|
Route::apiResource('playlist-folders.playlists', PlaylistFolderPlaylistController::class)->except('destroy');
|
|
|
|
Route::delete(
|
|
|
|
'playlist-folders/{playlistFolder}/playlists',
|
|
|
|
[PlaylistFolderPlaylistController::class, 'destroy']
|
|
|
|
);
|
2022-06-10 10:47:46 +00:00
|
|
|
|
|
|
|
// Playlist routes
|
2023-06-05 21:46:41 +00:00
|
|
|
Route::apiResource('playlists', PlaylistController::class);
|
|
|
|
Route::apiResource('playlists.songs', PlaylistSongController::class)->except('destroy');
|
|
|
|
Route::delete('playlists/{playlist}/songs', [PlaylistSongController::class, 'destroy']);
|
2024-01-29 21:58:50 +00:00
|
|
|
Route::post('playlists/{playlist}/songs/move', MovePlaylistSongsController::class);
|
2023-06-05 21:46:41 +00:00
|
|
|
|
|
|
|
Route::get('genres/{genre}/songs', GenreSongController::class)->where('genre', '.*');
|
|
|
|
Route::get('genres/{genre}/songs/random', FetchRandomSongsInGenreController::class)->where('genre', '.*');
|
|
|
|
Route::apiResource('genres', GenreController::class)->where(['genre' => '.*']);
|
2022-06-10 10:47:46 +00:00
|
|
|
|
2023-06-05 21:46:41 +00:00
|
|
|
Route::apiResource('users', UserController::class);
|
2022-06-10 10:47:46 +00:00
|
|
|
|
|
|
|
// User and user profile routes
|
2023-06-05 21:46:41 +00:00
|
|
|
Route::apiResource('user', UserController::class);
|
2022-06-10 10:47:46 +00:00
|
|
|
Route::get('me', [ProfileController::class, 'show']);
|
|
|
|
Route::put('me', [ProfileController::class, 'update']);
|
2024-01-23 22:50:50 +00:00
|
|
|
Route::patch('me/preferences', UpdateUserPreferenceController::class);
|
2022-06-10 10:47:46 +00:00
|
|
|
|
|
|
|
// Last.fm-related routes
|
2024-01-02 12:07:37 +00:00
|
|
|
Route::post('lastfm/session-key', SetLastfmSessionKeyController::class);
|
|
|
|
Route::delete('lastfm/disconnect', DisconnectFromLastfmController::class)->name('lastfm.disconnect');
|
2022-06-10 10:47:46 +00:00
|
|
|
|
|
|
|
// YouTube-related routes
|
|
|
|
if (YouTube::enabled()) {
|
2024-01-02 12:07:37 +00:00
|
|
|
Route::get('youtube/search/song/{song}', SearchYouTubeController::class);
|
2022-06-10 10:47:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Media information routes
|
2023-06-05 21:46:41 +00:00
|
|
|
Route::get('albums/{album}/information', FetchAlbumInformationController::class);
|
|
|
|
Route::get('artists/{artist}/information', FetchArtistInformationController::class);
|
2022-06-10 10:47:46 +00:00
|
|
|
|
|
|
|
// Cover/image upload routes
|
2024-02-24 15:37:01 +00:00
|
|
|
Route::put('albums/{album}/cover', UploadAlbumCoverController::class);
|
|
|
|
Route::get('albums/{album}/thumbnail', FetchAlbumThumbnailController::class);
|
|
|
|
Route::put('artists/{artist}/image', UploadArtistImageController::class);
|
|
|
|
Route::put('playlists/{playlist}/cover', UploadPlaylistCoverController::class);
|
|
|
|
// deprecated routes
|
2024-01-02 12:07:37 +00:00
|
|
|
Route::put('album/{album}/cover', UploadAlbumCoverController::class);
|
|
|
|
Route::get('album/{album}/thumbnail', FetchAlbumThumbnailController::class);
|
2024-02-24 15:37:01 +00:00
|
|
|
Route::put('artist/{artist}/image', UploadArtistImageController::class);
|
2022-06-10 10:47:46 +00:00
|
|
|
|
2023-06-05 21:46:41 +00:00
|
|
|
Route::get('search', ExcerptSearchController::class);
|
|
|
|
Route::get('search/songs', SongSearchController::class);
|
2023-08-23 22:10:36 +00:00
|
|
|
|
|
|
|
Route::post('invitations', [UserInvitationController::class, 'invite']);
|
|
|
|
Route::delete('invitations', [UserInvitationController::class, 'revoke']);
|
2024-01-08 22:21:21 +00:00
|
|
|
|
2024-01-16 21:14:14 +00:00
|
|
|
Route::put('songs/publicize', PublicizeSongsController::class);
|
|
|
|
Route::put('songs/privatize', PrivatizeSongsController::class);
|
2024-01-13 17:57:24 +00:00
|
|
|
|
2024-01-18 11:13:05 +00:00
|
|
|
// License routes
|
2024-01-13 17:57:24 +00:00
|
|
|
Route::post('licenses/activate', ActivateLicenseController::class);
|
2024-01-18 11:13:05 +00:00
|
|
|
|
|
|
|
// Playlist collaboration routes
|
|
|
|
Route::post('playlists/{playlist}/collaborators/invite', CreatePlaylistCollaborationTokenController::class);
|
2024-01-24 22:39:47 +00:00
|
|
|
Route::post('playlists/collaborators/accept', AcceptPlaylistCollaborationInviteController::class);
|
|
|
|
Route::get('playlists/{playlist}/collaborators', [PlaylistCollaboratorController::class, 'index']);
|
|
|
|
Route::delete('playlists/{playlist}/collaborators', [PlaylistCollaboratorController::class, 'destroy']);
|
2022-06-10 10:47:46 +00:00
|
|
|
});
|
|
|
|
|
2022-07-16 22:42:29 +00:00
|
|
|
// Object-storage (S3) routes
|
2022-06-10 10:47:46 +00:00
|
|
|
Route::middleware('os.auth')->prefix('os/s3')->group(static function (): void {
|
|
|
|
Route::post('song', [S3SongController::class, 'put'])->name('s3.song.put'); // we follow AWS's convention here.
|
|
|
|
Route::delete('song', [S3SongController::class, 'remove'])->name('s3.song.remove'); // and here.
|
|
|
|
});
|
2022-08-04 08:34:13 +00:00
|
|
|
|
2024-02-28 04:37:27 +00:00
|
|
|
Route::get('demo/credits', FetchDemoCreditsController::class);
|
2022-06-10 10:47:46 +00:00
|
|
|
});
|