Always allow specifying a page size with the API; closes #3218

This commit is contained in:
Dane Everitt 2021-03-26 09:03:51 -07:00
parent 9b46d59045
commit 48ad8f538e
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
8 changed files with 10 additions and 9 deletions

View file

@ -43,7 +43,7 @@ class AllocationController extends ApplicationApiController
*/
public function index(GetAllocationsRequest $request, Node $node): array
{
$allocations = $node->allocations()->paginate(50);
$allocations = $node->allocations()->paginate($request->query('per_page') ?? 50);
return $this->fractal->collection($allocations)
->transformWith($this->getTransformer(AllocationTransformer::class))
@ -53,6 +53,7 @@ class AllocationController extends ApplicationApiController
/**
* Store new allocations for a given node.
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Service\Allocation\CidrOutOfRangeException
* @throws \Pterodactyl\Exceptions\Service\Allocation\InvalidPortMappingException
* @throws \Pterodactyl\Exceptions\Service\Allocation\PortOutOfRangeException

View file

@ -64,7 +64,7 @@ class NodeController extends ApplicationApiController
$nodes = QueryBuilder::for(Node::query())
->allowedFilters(['uuid', 'name', 'fqdn', 'daemon_token_id'])
->allowedSorts(['id', 'uuid', 'memory', 'disk'])
->paginate(100);
->paginate($request->query('per_page') ?? 50);
return $this->fractal->collection($nodes)
->transformWith($this->getTransformer(NodeTransformer::class))

View file

@ -37,7 +37,7 @@ class NodeDeploymentController extends ApplicationApiController
$nodes = $this->viableNodesService->setLocations($data['location_ids'] ?? [])
->setMemory($data['memory'])
->setDisk($data['disk'])
->handle($request->input('page') ?? 0);
->handle($request->query('per_page'), $request->query('page'));
return $this->fractal->collection($nodes)
->transformWith($this->getTransformer(NodeTransformer::class))