koel/routes/api.php

97 lines
4 KiB
PHP
Raw Normal View History

2015-12-13 12:42:28 +08:00
<?php
2017-08-25 01:31:55 +01:00
use Illuminate\Http\Request;
2016-09-26 14:30:00 +08:00
Route::group(['namespace' => 'API'], function () {
2016-05-30 13:50:59 +08:00
Route::post('me', 'AuthController@login');
Route::delete('me', 'AuthController@logout');
2015-12-13 12:42:28 +08:00
2015-12-30 11:14:47 +07:00
Route::group(['middleware' => 'jwt.auth'], function () {
2018-05-01 20:38:14 +02:00
Route::get('/ping', function () {
2016-01-17 10:45:59 +08:00
// Just acting as a ping service.
2015-12-30 11:14:47 +07:00
});
2015-12-13 12:42:28 +08:00
2017-08-25 01:31:55 +01:00
Route::post('broadcasting/auth', 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,
]
);
2017-08-25 01:39:03 +01:00
2017-08-25 01:31:55 +01:00
return $pusher->socket_auth($request->channel_name, $request->socket_id);
});
2015-12-30 11:14:47 +07:00
Route::get('data', 'DataController@index');
2015-12-13 12:42:28 +08:00
2016-05-30 13:50:59 +08:00
Route::post('settings', 'SettingController@store');
2015-12-13 12:42:28 +08:00
Route::get('{song}/play/{transcode?}/{bitrate?}', 'SongController@play');
2016-05-30 13:50:59 +08:00
Route::post('{song}/scrobble/{timestamp}', 'ScrobbleController@store')->where([
2015-12-30 11:14:47 +07:00
'timestamp' => '\d+',
]);
2016-05-30 13:50:59 +08:00
Route::get('{song}/info', 'SongController@show');
2016-03-05 17:01:12 +08:00
Route::put('songs', 'SongController@update');
2016-06-03 01:53:26 +08:00
// Interaction routes
2017-08-06 10:43:59 +01:00
Route::post('interaction/play', 'Interaction\PlayCountController@store');
Route::post('interaction/like', 'Interaction\LikeController@store');
Route::post('interaction/batch/like', 'Interaction\BatchLikeController@store');
Route::post('interaction/batch/unlike', 'Interaction\BatchLikeController@destroy');
2015-12-13 12:42:28 +08:00
2016-06-03 01:53:26 +08:00
// Playlist routes
2016-01-25 18:37:14 +08:00
Route::resource('playlist', 'PlaylistController');
2015-12-30 11:14:47 +07:00
Route::put('playlist/{playlist}/sync', 'PlaylistController@sync')->where(['playlist' => '\d+']);
Route::get('playlist/{playlist}/songs', 'PlaylistController@getSongs')->where(['playlist' => '\d+']);
2015-12-30 11:14:47 +07:00
2016-06-03 01:53:26 +08:00
// User and user profile routes
2015-12-30 11:14:47 +07:00
Route::resource('user', 'UserController', ['only' => ['store', 'update', 'destroy']]);
Route::get('me', 'ProfileController@show');
2016-05-30 13:50:59 +08:00
Route::put('me', 'ProfileController@update');
2015-12-30 11:14:47 +07:00
2016-06-03 01:53:26 +08:00
// Last.fm-related routes
2016-02-01 09:58:31 +08:00
Route::get('lastfm/connect', 'LastfmController@connect');
2016-01-26 14:32:29 +08:00
Route::post('lastfm/session-key', 'LastfmController@setSessionKey');
2015-12-30 11:14:47 +07:00
Route::get('lastfm/callback', [
'as' => 'lastfm.callback',
'uses' => 'LastfmController@callback',
]);
Route::delete('lastfm/disconnect', 'LastfmController@disconnect');
2016-06-03 01:53:26 +08:00
2016-07-14 16:47:50 +08:00
// YouTube-related routes
if (YouTube::enabled()) {
Route::get('youtube/search/song/{song}', 'YouTubeController@searchVideosRelatedToSong');
}
2016-06-03 01:53:26 +08:00
// Download routes
Route::group(['prefix' => 'download', 'namespace' => 'Download'], function () {
Route::get('songs', 'SongController@download');
Route::get('album/{album}', 'AlbumController@download');
Route::get('artist/{artist}', 'ArtistController@download');
Route::get('playlist/{playlist}', 'PlaylistController@download');
2016-06-04 21:42:12 +08:00
Route::get('favorites', 'FavoritesController@download');
2016-06-03 01:53:26 +08:00
});
2016-06-05 12:37:03 +08:00
// Info routes
if (Lastfm::used()) {
2017-08-06 10:43:59 +01:00
Route::get('album/{album}/info', 'AlbumInfoController@show');
Route::get('artist/{artist}/info', 'ArtistInfoController@show');
}
2016-12-11 21:08:30 +08:00
// iTunes routes
if (iTunes::used()) {
Route::get('itunes/song/{album}', 'iTunesController@viewSong');
}
2015-12-30 11:14:47 +07:00
});
2016-06-13 17:04:42 +08:00
Route::group(['middleware' => 'os.auth', 'prefix' => 'os', 'namespace' => 'ObjectStorage'], function () {
Route::group(['prefix' => 's3', 'namespace' => 'S3'], function () {
Route::post('song', 'SongController@put'); // we follow AWS's convention here.
Route::delete('song', 'SongController@remove'); // and here.
});
});
2015-12-13 12:42:28 +08:00
});