Skip to content

Commit

Permalink
chore: ...
Browse files Browse the repository at this point in the history
  • Loading branch information
BibaltiK committed Jul 26, 2024
1 parent cece5e8 commit 3d01c0e
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ MYSQL_PASSWORD=dev
MYSQL_ROOT_PASSWORD=root
MYSQL_DATABASE=db
MYSQL_PUBLIC_PORT=3306
PHP_VERSION=8.2
PHP_VERSION=8.3
MARIADB_VERSION=latest
APACHE_VERSION=2.4-alpine
HTTP_PORT=80
Expand Down
10 changes: 9 additions & 1 deletion config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Mezzio\Application;
use Mezzio\MiddlewareFactory;
use Psr\Container\ContainerInterface;
use Stormannsgal\App\Handler\Account\AccountCreateHandler;
use Stormannsgal\App\Handler\Account\ListAllAccountsHandler;
use Stormannsgal\App\Handler\PingHandler;
use Stormannsgal\Core\Config\RouteName;
Expand Down Expand Up @@ -41,6 +42,13 @@
*/

return static function (Application $app, MiddlewareFactory $factory, ContainerInterface $container): void {
$app->get('/api/ping', PingHandler::class, RouteName::HANDLER_PING);
$app->get('/api/ping', PingHandler::class, RouteName::PING);
$app->post(
path: '/api/account',
middleware: [
AccountCreateHandler::class,
],
name: RouteName::ACCOUNT_CREATE
);
$app->get('/api/account/list/all', ListAllAccountsHandler::class, ListAllAccountsHandler::class);
};
18 changes: 18 additions & 0 deletions public/api/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
"version": "0.0.1"
},
"paths": {
"/api/account": {
"post": {
"tags": [
"Account"
],
"summary": "Create new Account",
"description": "Create new Account",
"operationId": "902abdfc53a8327ba1a105a002a1e1f1",
"responses": {
"200": {
"description": "Success"
},
"401": {
"description": "Unauthorized"
}
}
}
},
"/api/account/list/all": {
"get": {
"tags": [
Expand Down
26 changes: 26 additions & 0 deletions src/App/Handler/Account/AccountCreateHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php declare(strict_types=1);

namespace Stormannsgal\App\Handler\Account;

use Fig\Http\Message\StatusCodeInterface as HTTP;
use Laminas\Diactoros\Response\JsonResponse;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use OpenApi\Attributes as OA;

class AccountCreateHandler implements RequestHandlerInterface
{
#[OA\Post(
path: '/api/account',
description: 'Create new Account',
summary: 'Create new Account',
tags: ['Account']
)]
#[OA\Response(response: HTTP::STATUS_OK, description: 'Success')]
#[OA\Response(response: HTTP::STATUS_UNAUTHORIZED, description: 'Unauthorized')]
public function handle(ServerRequestInterface $request): ResponseInterface
{
return new JsonResponse([], HTTP::STATUS_OK);
}
}
4 changes: 3 additions & 1 deletion src/Core/Config/RouteName.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@

interface RouteName
{
public const HANDLER_PING = 'handler.ping';
public const PING = 'handler.ping';

public const ACCOUNT_CREATE = 'account.create';
}

0 comments on commit 3d01c0e

Please sign in to comment.