diff --git a/routes/api.php b/routes/api.php index a7284c1..81eabe8 100644 --- a/routes/api.php +++ b/routes/api.php @@ -8,6 +8,7 @@ use App\Http\Controllers\API\TopicsAPIController; use App\Http\Controllers\API\MyListAPIController; use App\Http\Controllers\API\NewsLetterAPIController; use App\Article; +use Illuminate\Support\Facades\Cache; /* |-------------------------------------------------------------------------- @@ -37,17 +38,19 @@ Route::post('newsletter/subscribe', [NewsLetterAPIController::class, 'store'])-> Route::get('/ping/{source}', \API\MonitorAPIController::class); -Route::get('/latest/webhook', function(){ - return Article::latest()->limit(20)->get()->transform(function ($article) { - return [ - "id" => $article->id, - "title" => $article->title, - "original" => $article->url, - "author" => $article->author, - "featured_image" => $article->featured_image, - "published_date" => $article->published_date, - "source" => $article->source->slug, - "link" => "https://karudhaas.net/article/{$article->source->slug}/{$article->guid}" - ]; +Route::get('/latest/webhook', function () { + return Cache::remember('webhooks.latest', 60, function () { + return Article::latest()->limit(20)->get()->transform(function ($article) { + return [ + "id" => $article->id, + "title" => $article->title, + "original" => $article->url, + "author" => $article->author, + "featured_image" => $article->featured_image, + "published_date" => $article->published_date, + "source" => $article->source->slug, + "link" => "https://karudhaas.net/article/{$article->source->slug}/{$article->guid}" + ]; + }); }); -}); \ No newline at end of file +});