feat: group web routes under web/

This commit is contained in:
Phan An 2020-09-07 23:03:22 +02:00
parent 84b05c449f
commit 448d33c2c3
6 changed files with 16 additions and 16 deletions

View file

@ -16,7 +16,7 @@
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Whitelist only index.php, robots.txt, and some special routes
RewriteRule ^(?!($|index\.php|robots\.txt|(public|api)/|remote|api-docs|sw\.js)) - [R=404,L]
RewriteRule ^(?!($|index\.php|robots\.txt|(public|api|web)/|remote|api-docs|sw\.js)) - [R=404,L]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d

View file

@ -9,7 +9,7 @@ server {
gzip_comp_level 9;
# Whitelist only index.php, robots.txt, and some special routes
if ($request_uri !~ ^/$|index\.php|robots\.txt|(public|api)/|remote|api-docs|sw\.js) {
if ($request_uri !~ ^/$|index\.php|robots\.txt|(public|api|web)/|remote|api-docs|sw\.js) {
return 404;
}

@ -1 +1 @@
Subproject commit af31eddbc2ae71c46d403f985c06e79ad52ae11b
Subproject commit 8014802756cdefa337a0de226fc5cce932d03d57

View file

@ -11,7 +11,7 @@ Route::get('/remote', static function () {
return view('remote');
});
Route::group(['middleware' => 'auth'], static function (): void {
Route::group(['middleware' => 'auth', 'prefix' => 'web'], static function (): void {
Route::get('/{song}/play/{transcode?}/{bitrate?}', 'PlayController@show')
->name('song.play');

View file

@ -41,7 +41,7 @@ class DownloadTest extends TestCase
->shouldReceive('from')
->never();
$this->get("download/songs?songs[]={$song->id}")
$this->get("web/download/songs?songs[]={$song->id}")
->assertRedirect('/');
}
@ -60,7 +60,7 @@ class DownloadTest extends TestCase
}))
->andReturn($this->mediaPath.'/blank.mp3');
$this->get("download/songs?songs[]={$song->id}&api_token=".$user->createToken('Koel')->plainTextToken)
$this->get("web/download/songs?songs[]={$song->id}&api_token=".$user->createToken('Koel')->plainTextToken)
->assertOk();
}
@ -83,7 +83,7 @@ class DownloadTest extends TestCase
->andReturn($this->mediaPath.'/blank.mp3'); // should be a zip file, but we're testing here…
$this->get(
"download/songs?songs[]={$songs[0]->id}&songs[]={$songs[1]->id}&api_token="
"web/download/songs?songs[]={$songs[0]->id}&songs[]={$songs[1]->id}&api_token="
.$user->createToken('Koel')->plainTextToken
)
->assertOk();
@ -104,7 +104,7 @@ class DownloadTest extends TestCase
}))
->andReturn($this->mediaPath.'/blank.mp3');
$this->get("download/album/{$album->id}?api_token=".$user->createToken('Koel')->plainTextToken)
$this->get("web/download/album/{$album->id}?api_token=".$user->createToken('Koel')->plainTextToken)
->assertOk();
}
@ -123,7 +123,7 @@ class DownloadTest extends TestCase
}))
->andReturn($this->mediaPath.'/blank.mp3');
$this->get("download/artist/{$artist->id}?api_token=".$user->createToken('Koel')->plainTextToken)
$this->get("web/download/artist/{$artist->id}?api_token=".$user->createToken('Koel')->plainTextToken)
->assertOk();
}
@ -145,7 +145,7 @@ class DownloadTest extends TestCase
->once()
->andReturn($this->mediaPath.'/blank.mp3');
$this->get("download/playlist/{$playlist->id}?api_token=".$user->createToken('Koel')->plainTextToken)
$this->get("web/download/playlist/{$playlist->id}?api_token=".$user->createToken('Koel')->plainTextToken)
->assertOk();
}
@ -157,7 +157,7 @@ class DownloadTest extends TestCase
/** @var User $user */
$user = factory(User::class)->create();
$this->get("download/playlist/{$playlist->id}?api_token=".$user->createToken('Koel')->plainTextToken)
$this->get("web/download/playlist/{$playlist->id}?api_token=".$user->createToken('Koel')->plainTextToken)
->assertStatus(Response::HTTP_FORBIDDEN);
}
@ -181,7 +181,7 @@ class DownloadTest extends TestCase
->once()
->andReturn($this->mediaPath.'/blank.mp3');
$this->get('download/favorites?api_token='.$user->createToken('Koel')->plainTextToken)
$this->get('web/download/favorites?api_token='.$user->createToken('Koel')->plainTextToken)
->assertOk();
}
}

View file

@ -56,9 +56,9 @@ class LastfmTest extends TestCase
->with($user)
->andReturn($temporaryToken);
$this->get('lastfm/connect?api_token='.$token)
$this->get('web/lastfm/connect?api_token='.$token)
->assertRedirect(
'https://www.last.fm/api/auth/?api_key=foo&cb=http%3A%2F%2Flocalhost%2Flastfm%2Fcallback%3Fapi_token%3Dtmp-token'
'https://www.last.fm/api/auth/?api_key=foo&cb=http%3A%2F%2Flocalhost%2Fweb%2Flastfm%2Fcallback%3Fapi_token%3Dtmp-token'
);
}
@ -77,7 +77,7 @@ class LastfmTest extends TestCase
->once()
->andReturn('my-session-key');
$this->get('lastfm/callback?token=lastfm-token&api_token='.urlencode($token))
$this->get('web/lastfm/callback?token=lastfm-token&api_token='.urlencode($token))
->assertOk();
self::assertSame('my-session-key', $user->refresh()->lastfm_session_key);
@ -102,7 +102,7 @@ class LastfmTest extends TestCase
->with('my-token')
->andReturn($user);
$this->get('lastfm/callback?token=foo&api_token=my-token');
$this->get('web/lastfm/callback?token=foo&api_token=my-token');
self::assertEquals('bar', $user->refresh()->lastfm_session_key);
}