2022-11-06 11:28:22 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
|
|
|
use Illuminate\Cache\RateLimiting\Limit;
|
|
|
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Support\Facades\RateLimiter;
|
|
|
|
use Illuminate\Support\Facades\Route;
|
|
|
|
|
|
|
|
class RouteServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The path to the "home" route for your application.
|
|
|
|
*
|
|
|
|
* Typically, users are redirected here after authentication.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2022-11-07 01:18:26 +00:00
|
|
|
public const HOME = '/';
|
2022-11-06 11:28:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Define your route model bindings, pattern filters, and other route configuration.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2023-01-10 13:42:27 +00:00
|
|
|
public function boot(): void
|
2022-11-06 11:28:22 +00:00
|
|
|
{
|
|
|
|
$this->configureRateLimiting();
|
|
|
|
|
|
|
|
$this->routes(function () {
|
2023-01-14 21:37:25 +00:00
|
|
|
Route::middleware(['api', 'auth:sanctum', 'real_named:sanctum'])
|
2022-11-06 11:28:22 +00:00
|
|
|
->prefix('api')
|
2022-11-06 15:46:57 +00:00
|
|
|
->as('api.')
|
2022-11-06 11:28:22 +00:00
|
|
|
->group(base_path('routes/api.php'));
|
|
|
|
|
2022-11-23 09:34:18 +00:00
|
|
|
Route::middleware(['module', 'auth:module'])
|
2022-11-16 02:29:50 +00:00
|
|
|
->prefix('modules')
|
|
|
|
->as('modules.')
|
|
|
|
->group(base_path('routes/modules.php'));
|
2022-11-06 14:57:01 +00:00
|
|
|
|
2022-11-27 02:34:36 +00:00
|
|
|
Route::middleware(['module', 'auth:application'])
|
|
|
|
->prefix('applications')
|
|
|
|
->as('applications.')
|
|
|
|
->group(base_path('routes/applications.php'));
|
|
|
|
|
2023-02-02 11:22:11 +00:00
|
|
|
Route::middleware(['web', 'admin.validateReferer', 'auth:admin'])
|
2022-11-14 10:37:09 +00:00
|
|
|
->prefix('admin')
|
|
|
|
->as('admin.')
|
|
|
|
->group(base_path('routes/admin.php'));
|
|
|
|
|
2022-11-06 11:28:22 +00:00
|
|
|
Route::middleware('web')
|
|
|
|
->group(base_path('routes/web.php'));
|
2023-01-14 21:37:25 +00:00
|
|
|
|
|
|
|
Route::middleware(['api'])
|
|
|
|
->prefix('public')
|
|
|
|
->as('public.')
|
|
|
|
->group(base_path('routes/public.php'));
|
2022-11-06 11:28:22 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Configure the rate limiters for the application.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2023-01-01 14:03:07 +00:00
|
|
|
protected function configureRateLimiting(): void
|
2022-11-06 11:28:22 +00:00
|
|
|
{
|
|
|
|
RateLimiter::for('api', function (Request $request) {
|
2023-01-01 14:09:48 +00:00
|
|
|
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
|
2022-11-06 11:28:22 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|