forked from alexjustesen/speedtest-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.php
More file actions
45 lines (37 loc) · 1.42 KB
/
api.php
File metadata and controls
45 lines (37 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
use App\Http\Controllers\API\HealthCheckController;
use App\Http\Controllers\API\Speedtest\GetLatestController;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Route;
use Symfony\Component\Console\Output\BufferedOutput;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::middleware('auth:sanctum')->group(function () {
/**
* About endpoint will return the current status of the application including it's version.
*
* Endpoint: /api/about
*/
Route::get('/about', function () {
$output = new BufferedOutput();
Artisan::call('about --json', [], $output);
$response = json_decode($output->fetch(), true);
return response()->json($response);
});
});
Route::get('/healthcheck', HealthCheckController::class);
/**
* This route provides backwards compatibility from https://github.com/henrywhitaker3/Speedtest-Tracker
* for Homepage and Organizr dashboards which expects the returned
* download and upload values in mbits.
*/
Route::get('/speedtest/latest', GetLatestController::class)
->name('speedtest.latest');