You've already forked Php-Template
All checks were successful
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 4m0s
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 4m11s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 4m22s
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 4m42s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 4m27s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 2m55s
63 lines
1.7 KiB
PHP
63 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Siteworxpro\App\Controllers;
|
|
|
|
use Nyholm\Psr7\ServerRequest;
|
|
use Psr\Http\Message\ResponseInterface;
|
|
use Siteworxpro\App\Attributes\Guards;
|
|
use Siteworxpro\App\Http\JsonResponseFactory;
|
|
use OpenApi\Attributes as OA;
|
|
|
|
/**
|
|
* Class IndexController
|
|
*
|
|
* This class handles the index route of the application.
|
|
*/
|
|
class IndexController extends Controller
|
|
{
|
|
/**
|
|
* Handles the GET request for the index route.
|
|
*
|
|
* @throws \JsonException
|
|
*/
|
|
#[Guards\Jwt]
|
|
#[Guards\Scope(['get.index', 'status.check'])]
|
|
#[Guards\RequireAllScopes]
|
|
#[OA\Get(path: '/')]
|
|
#[OA\Response(
|
|
response: '200',
|
|
description: 'An Example Response',
|
|
content: new OA\JsonContent(properties: [
|
|
new OA\Property('status_code', type: 'integer'),
|
|
new OA\Property('message', type: 'string'),
|
|
])
|
|
)]
|
|
public function get(ServerRequest $request): ResponseInterface
|
|
{
|
|
return JsonResponseFactory::createJsonResponse(['status_code' => 200, 'message' => 'Server is running']);
|
|
}
|
|
|
|
/**
|
|
* @throws \JsonException
|
|
*/
|
|
#[Guards\Jwt]
|
|
#[Guards\Scope(['post.index'])]
|
|
#[OA\Post(path: '/')]
|
|
#[OA\Response(
|
|
response: '200',
|
|
description: 'An Example Response',
|
|
content: new OA\JsonContent(
|
|
properties: [
|
|
new OA\Property('status_code', type: 'integer'),
|
|
new OA\Property('message', type: 'string'),
|
|
]
|
|
)
|
|
)]
|
|
public function post(ServerRequest $request): ResponseInterface
|
|
{
|
|
return JsonResponseFactory::createJsonResponse(['status_code' => 200, 'message' => 'Server is running']);
|
|
}
|
|
}
|