-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
125 changed files
with
2,514 additions
and
288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
data: | ||
mate: | ||
presets: [moderntv] | ||
|
||
app: | ||
scopes: [database, bus, api] | ||
|
||
structs: | ||
user: | ||
fields: | ||
username: {type: string} | ||
email: {type: string} | ||
password: {type: string} | ||
createdAt: {type: Nette\Utils\DateTime} | ||
updatedAt: {type: Nette\Utils\DateTime} | ||
roles: {type: array} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace App\Api\User\Create; | ||
|
||
use App\Api\AbstractController; | ||
use App\Model\Api\Request\RequestFactory; | ||
use Contributte\FrameX\Http\IResponse; | ||
use Moderntv\Messenger\Bus\CommandBus; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
|
||
final class CreateUserController extends AbstractController | ||
{ | ||
|
||
public function __construct( | ||
private readonly CommandBus $bus, | ||
private readonly RequestFactory $requestFactory, | ||
) | ||
{ | ||
} | ||
|
||
public function __invoke(ServerRequestInterface $serverRequest): IResponse | ||
{ | ||
// TODO | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace App\Api\User\Create; | ||
|
||
final readonly class CreateUserRequest | ||
{ | ||
|
||
public function __construct( | ||
public CreateUserRequestBody $body, | ||
) | ||
{ | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
examples/d01/app/Api/User/Create/CreateUserRequestBody.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace App\Api\User\Create; | ||
|
||
use App\Domain\User\Database\User; | ||
use Nette\Schema\Expect; | ||
use Nette\Schema\Schema; | ||
|
||
final class CreateUserRequestBody | ||
{ | ||
|
||
public string $username; | ||
|
||
public string $email; | ||
|
||
public string $password; | ||
|
||
public Nette\Utils\DateTime $createdAt; | ||
|
||
public Nette\Utils\DateTime $updatedAt; | ||
|
||
public array $roles; | ||
|
||
public static function schema(): Schema | ||
{ | ||
return Expect::structure([ | ||
'username' => Expect::string()->required(), | ||
'email' => Expect::string()->required(), | ||
'password' => Expect::string()->required(), | ||
'createdAt' => Expect::string()->required(), | ||
'updatedAt' => Expect::string()->required(), | ||
'roles' => Expect::string()->required(), | ||
])->castTo(self::class); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace App\Api\User\Create; | ||
|
||
use Contributte\FrameX\Http\EntityResponse; | ||
|
||
final class CreateUserResponse extends EntityResponse | ||
{ | ||
|
||
public static function of(UserDto $dto): self | ||
{ | ||
$self = self::create(); | ||
$self->payload = $dto; | ||
|
||
return $self; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace App\Api\User\Delete; | ||
|
||
use App\Api\AbstractController; | ||
use App\Model\Api\Request\RequestFactory; | ||
use Contributte\FrameX\Http\IResponse; | ||
use Moderntv\Messenger\Bus\CommandBus; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
|
||
final class DeleteUserController extends AbstractController | ||
{ | ||
|
||
public function __construct( | ||
private readonly CommandBus $bus, | ||
private readonly RequestFactory $requestFactory, | ||
) | ||
{ | ||
} | ||
|
||
public function __invoke(ServerRequestInterface $serverRequest): IResponse | ||
{ | ||
// TODO | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace App\Api\User\Delete; | ||
|
||
use Contributte\FrameX\Http\DataResponse; | ||
|
||
final class DeleteUserResponse extends DataResponse | ||
{ | ||
|
||
public static function of(): self | ||
{ | ||
$self = self::create(); | ||
|
||
return $self; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace App\Api\User\Get; | ||
|
||
use App\Api\AbstractController; | ||
use App\Model\Api\Request\RequestFactory; | ||
use Contributte\FrameX\Http\IResponse; | ||
use Moderntv\Messenger\Bus\CommandBus; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
|
||
final class GetUserController extends AbstractController | ||
{ | ||
|
||
public function __construct( | ||
private readonly CommandBus $bus, | ||
private readonly RequestFactory $requestFactory, | ||
) | ||
{ | ||
} | ||
|
||
public function __invoke(ServerRequestInterface $serverRequest): IResponse | ||
{ | ||
// TODO | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace App\Api\User\Get; | ||
|
||
final readonly class GetUserRequest | ||
{ | ||
|
||
public function __construct( | ||
) | ||
{ | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace App\Api\User\Get; | ||
|
||
use Contributte\FrameX\Http\EntityResponse; | ||
|
||
final class GetUserResponse extends EntityResponse | ||
{ | ||
|
||
public static function of(UserDto $dto): self | ||
{ | ||
$self = self::create(); | ||
$self->payload = $dto; | ||
|
||
return $self; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace App\Api\User\List; | ||
|
||
use App\Api\AbstractController; | ||
use App\Model\Api\Request\RequestFactory; | ||
use Contributte\FrameX\Http\IResponse; | ||
use Moderntv\Messenger\Bus\CommandBus; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
|
||
final class ListUserController extends AbstractController | ||
{ | ||
|
||
public function __construct( | ||
private readonly CommandBus $bus, | ||
private readonly RequestFactory $requestFactory, | ||
) | ||
{ | ||
} | ||
|
||
public function __invoke(ServerRequestInterface $serverRequest): IResponse | ||
{ | ||
// TODO | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace App\Api\User\List; | ||
|
||
final readonly class ListUserRequest | ||
{ | ||
|
||
public function __construct( | ||
) | ||
{ | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace App\Api\User\List; | ||
|
||
use App\Model\Api\Request\RequestFilter; | ||
use Nette\Schema\Expect; | ||
use Nette\Schema\Schema; | ||
|
||
class ListUserRequestFilter extends RequestFilter | ||
{ | ||
|
||
public static function schema(): Schema | ||
{ | ||
return RequestFilter::extend([ | ||
'o' => Expect::structure([ | ||
'username' => Expect::anyOf('asc', 'desc'), | ||
])->required(false)->castTo('array'), | ||
'q' => Expect::structure([ | ||
'username' => Expect::string(), | ||
])->required(false)->castTo('array'), | ||
])->castTo(self::class); | ||
} | ||
|
||
} |
Oops, something went wrong.