mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 18:44:46 +02:00
Remove NodeCreationService
(#1092)
This commit is contained in:
parent
253abf65b1
commit
22d02c0df5
@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Console\Commands\Node;
|
||||
|
||||
use App\Models\Node;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Services\Nodes\NodeCreationService;
|
||||
|
||||
class MakeNodeCommand extends Command
|
||||
{
|
||||
@ -30,14 +30,6 @@ class MakeNodeCommand extends Command
|
||||
|
||||
protected $description = 'Creates a new node on the system via the CLI.';
|
||||
|
||||
/**
|
||||
* MakeNodeCommand constructor.
|
||||
*/
|
||||
public function __construct(private NodeCreationService $creationService)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the command execution process.
|
||||
*
|
||||
@ -69,7 +61,7 @@ class MakeNodeCommand extends Command
|
||||
$data['daemon_sftp_alias'] = $this->option('daemonSFTPAlias') ?? $this->ask(trans('commands.make_node.daemonSFTPAlias'), '');
|
||||
$data['daemon_base'] = $this->option('daemonBase') ?? $this->ask(trans('commands.make_node.daemonBase'), '/var/lib/pelican/volumes');
|
||||
|
||||
$node = $this->creationService->handle($data);
|
||||
$node = Node::create($data);
|
||||
$this->line(trans('commands.make_node.success', ['name' => $data['name'], 'id' => $node->id]));
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ use App\Models\Node;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Spatie\QueryBuilder\QueryBuilder;
|
||||
use App\Services\Nodes\NodeUpdateService;
|
||||
use App\Services\Nodes\NodeCreationService;
|
||||
use App\Services\Nodes\NodeDeletionService;
|
||||
use App\Transformers\Api\Application\NodeTransformer;
|
||||
use App\Http\Requests\Api\Application\Nodes\GetNodeRequest;
|
||||
@ -24,7 +23,6 @@ class NodeController extends ApplicationApiController
|
||||
* NodeController constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
private NodeCreationService $creationService,
|
||||
private NodeDeletionService $deletionService,
|
||||
private NodeUpdateService $updateService
|
||||
) {
|
||||
@ -74,7 +72,7 @@ class NodeController extends ApplicationApiController
|
||||
*/
|
||||
public function store(StoreNodeRequest $request): JsonResponse
|
||||
{
|
||||
$node = $this->creationService->handle($request->validated());
|
||||
$node = Node::create($request->validated());
|
||||
|
||||
return $this->fractal->item($node)
|
||||
->transformWith($this->getTransformer(NodeTransformer::class))
|
||||
|
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Nodes;
|
||||
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\Node;
|
||||
|
||||
class NodeCreationService
|
||||
{
|
||||
/**
|
||||
* Create a new node on the panel.
|
||||
*
|
||||
* @todo remove this class
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
*
|
||||
* @throws \App\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
public function handle(array $data): Node
|
||||
{
|
||||
$data['uuid'] = Uuid::uuid4()->toString();
|
||||
$data['daemon_token'] = Str::random(Node::DAEMON_TOKEN_LENGTH);
|
||||
$data['daemon_token_id'] = Str::random(Node::DAEMON_TOKEN_ID_LENGTH);
|
||||
|
||||
return Node::query()->create($data);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user