Skip to content

Commit

Permalink
✔️ add json status endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
dweissengruber committed Mar 9, 2021
1 parent 0175d87 commit 9bdd5c8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
29 changes: 29 additions & 0 deletions app/Http/Controllers/StatusReportController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Http\Controllers;

use App\Website;
use Illuminate\Http\Request;
use App\Jobs\CertificateCheck;

class StatusReportController extends Controller
{
/**
* Handle the incoming request.
*
* @param Request $request
* @return array
*/
public function __invoke(Request $request, Website $website)
{
$results = [];
foreach (Website::all() as $site) {
$results[$site->url]['uptime'] = $site->generateUptimeReport();
$results[$site->url]['ssl'] = $site->certificates()->latest()->first();
$results[$site->url]['dns'] = $site->last_dns_scans;
$results[$site->url]['robots'] = $site->last_robot_scans;
}

return $results;
}
}
2 changes: 2 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
Route::put('edit-account', '\Maelstrom\Http\Controllers\EditAccountController@update');
Route::post('logout', 'Auth\LoginController@logout')->name('maelstrom.logout');

Route::get('status', 'StatusReportController')->name('status');

Route::post('websites/bulk', 'WebsiteController@bulk')->name('websites.bulk');
Route::resource('websites', 'WebsiteController');
Route::get('websites/{website}/robots', 'RobotCompareController')->name('robots');
Expand Down

0 comments on commit 9bdd5c8

Please sign in to comment.