Route cache
This commit is contained in:
@@ -8,6 +8,7 @@ use App\Http\Controllers\API\TopicsAPIController;
|
|||||||
use App\Http\Controllers\API\MyListAPIController;
|
use App\Http\Controllers\API\MyListAPIController;
|
||||||
use App\Http\Controllers\API\NewsLetterAPIController;
|
use App\Http\Controllers\API\NewsLetterAPIController;
|
||||||
use App\Article;
|
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('/ping/{source}', \API\MonitorAPIController::class);
|
||||||
|
|
||||||
Route::get('/latest/webhook', function(){
|
Route::get('/latest/webhook', function () {
|
||||||
return Article::latest()->limit(20)->get()->transform(function ($article) {
|
return Cache::remember('webhooks.latest', 60, function () {
|
||||||
return [
|
return Article::latest()->limit(20)->get()->transform(function ($article) {
|
||||||
"id" => $article->id,
|
return [
|
||||||
"title" => $article->title,
|
"id" => $article->id,
|
||||||
"original" => $article->url,
|
"title" => $article->title,
|
||||||
"author" => $article->author,
|
"original" => $article->url,
|
||||||
"featured_image" => $article->featured_image,
|
"author" => $article->author,
|
||||||
"published_date" => $article->published_date,
|
"featured_image" => $article->featured_image,
|
||||||
"source" => $article->source->slug,
|
"published_date" => $article->published_date,
|
||||||
"link" => "https://karudhaas.net/article/{$article->source->slug}/{$article->guid}"
|
"source" => $article->source->slug,
|
||||||
];
|
"link" => "https://karudhaas.net/article/{$article->source->slug}/{$article->guid}"
|
||||||
|
];
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user