mirror of
https://github.com/HolgerHatGarKeineNode/einundzwanzig-app.git
synced 2025-12-14 12:06:46 +00:00
🛠️ Integrate Laravel Nightwatch and enhance middleware handling
- Added Laravel Nightwatch for advanced monitoring and user sampling. - Customized Livewire update route with rate-limiting middleware. - Introduced a global fallback route with 404 response and sampling middleware. - Enabled event listening for health diagnosis with Nightwatch sampling adjustments. - Refined lazy loading prevention in local environments.
This commit is contained in:
@@ -3,9 +3,16 @@
|
|||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use App\Support\Carbon;
|
use App\Support\Carbon;
|
||||||
|
use Illuminate\Contracts\Auth\Authenticatable;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Foundation\Events\DiagnosingHealth;
|
||||||
use Illuminate\Support\Facades\Date;
|
use Illuminate\Support\Facades\Date;
|
||||||
|
use Illuminate\Support\Facades\Event;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Laravel\Nightwatch\Facades\Nightwatch;
|
||||||
|
use Laravel\Nightwatch\Http\Middleware\Sample;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
@@ -24,6 +31,19 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
|
Livewire::setUpdateRoute(function ($handle) {
|
||||||
|
return Route::post('/livewire/update', $handle)
|
||||||
|
->middleware(['web', Sample::rate(0)]);
|
||||||
|
});
|
||||||
|
|
||||||
|
Nightwatch::user(fn (Authenticatable $user) => [
|
||||||
|
'name' => $user->name,
|
||||||
|
]);
|
||||||
|
|
||||||
|
Event::listen(function (DiagnosingHealth $event) {
|
||||||
|
Nightwatch::dontSample();
|
||||||
|
});
|
||||||
|
|
||||||
Model::preventLazyLoading(app()->environment('local'));
|
Model::preventLazyLoading(app()->environment('local'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use Laravel\Nightwatch\Http\Middleware\Sample;
|
||||||
use Livewire\Volt\Volt;
|
use Livewire\Volt\Volt;
|
||||||
|
|
||||||
Route::redirect('/', 'welcome');
|
Route::redirect('/', 'welcome');
|
||||||
@@ -118,4 +119,7 @@ Route::middleware(['auth'])
|
|||||||
|
|
||||||
//Route::feeds();
|
//Route::feeds();
|
||||||
|
|
||||||
|
Route::fallback(fn () => abort(404))
|
||||||
|
->middleware(Sample::rate(0.5));
|
||||||
|
|
||||||
require __DIR__.'/auth.php';
|
require __DIR__.'/auth.php';
|
||||||
|
|||||||
Reference in New Issue
Block a user