refactor(api): restructure root response to include versions

This commit is contained in:
Jérémy Munsch 2026-08-12 17:11:37 +02:00
parent c5867c7926
commit a738fed493
Signed by: forge-joniko
GPG key ID: D7EFE2F5CB6CC0E4
2 changed files with 13 additions and 3 deletions

View file

@ -6,8 +6,15 @@ use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Route;
// * Api Root URL
Route::get('/', fn () => response()->json(Config::string('app.name') . ' please choose a version'))
->name('api.root');
Route::get(
'/',
fn () => response()->json([
'message' => Config::string('app.name') . ' please choose a version',
'versions' => [
'v1' => route('api.v1.root'),
],
])
)->name('api.root');
// * V1 API
Route::prefix('v1')->name('api.v1.')->group(function () {

View file

@ -7,7 +7,10 @@ use Illuminate\Support\Facades\Route;
use Presentation\Api\V1\Http\Controllers\Employees\EmployeeShowController;
use Presentation\Api\V1\Http\Controllers\Employees\EmployeesIndexController;
Route::get('/', fn () => response()->json(Config::string('app.name') . ' v1'))->name('root');
Route::get('/', fn () => response()->json([
'message' => Config::string('app.name') . ' v1',
'spec' => route('api.v1.openapi'),
]))->name('root');
Route::get('/ping', fn () => response()->json('pong'))->name('ping');