Consolidate service providers

This commit is contained in:
Shift
2024-04-05 18:36:48 +00:00
parent 952cada198
commit 7a07548748
2 changed files with 23 additions and 1 deletions

View File

@@ -11,10 +11,22 @@
namespace App\Providers;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* The path to your application's "home" route.
*
* Typically, users are redirected here after authentication.
*
* @var string
*/
public const HOME = '/home';
/**
* Register any application services.
*/
@@ -29,5 +41,14 @@ class AppServiceProvider extends ServiceProvider
public function boot(): void
{
//
$this->bootRoute();
}
public function bootRoute(): void
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
});
}
}