Shift service providers

This commit is contained in:
Shift
2023-01-07 20:33:06 +00:00
parent cd9b2383a6
commit 2e6e296715
2 changed files with 25 additions and 16 deletions

View File

@@ -25,7 +25,6 @@ class EventServiceProvider extends ServiceProvider
*/
public function boot()
{
parent::boot();
//
}

View File

@@ -2,6 +2,9 @@
namespace App\Providers;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Http\Request;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;
@@ -30,23 +33,18 @@ class RouteServiceProvider extends ServiceProvider
*/
public function boot()
{
//
parent::boot();
$this->configureRateLimiting();
$this->routes(function () {
$this->mapApiRoutes();
$this->mapWebRoutes();
$this->mapInstallerRoutes();
$this->mapUpdateRoutes();
//
});
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
$this->mapInstallerRoutes();
$this->mapUpdateRoutes();
//
}
/**
* Define the "web" routes for the application.
@@ -117,4 +115,16 @@ class RouteServiceProvider extends ServiceProvider
require base_path('routes/update.php');
});
}
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
});
}
}