diff --git a/app/Http/Controllers/API/Admin/NodeController.php b/app/Http/Controllers/API/Admin/NodeController.php index a88d5054b..655a7575d 100644 --- a/app/Http/Controllers/API/Admin/NodeController.php +++ b/app/Http/Controllers/API/Admin/NodeController.php @@ -32,6 +32,7 @@ use Pterodactyl\Exceptions\DisplayException; use Pterodactyl\Repositories\NodeRepository; use Pterodactyl\Transformers\Admin\NodeTransformer; use Pterodactyl\Exceptions\DisplayValidationException; +use League\Fractal\Pagination\IlluminatePaginatorAdapter; class NodeController extends Controller { @@ -45,14 +46,17 @@ class NodeController extends Controller { $this->authorize('node-list', $request->apiKey()); - $fractal = Fractal::create()->collection(Node::all()); - if ($request->input('include')) { + $nodes = Node::paginate(config('pterodactyl.paginate.api.nodes')); + $fractal = Fractal::create()->collection($nodes) + ->transformWith(new NodeTransformer($request)) + ->withResourceName('user') + ->paginateWith(new IlluminatePaginatorAdapter($nodes)); + + if (config('pterodactyl.api.allow_includes_on_list') && $request->input('include')) { $fractal->parseIncludes(explode(',', $request->input('include'))); } - return $fractal->transformWith(new NodeTransformer($request)) - ->withResourceName('node') - ->toArray(); + return $fractal->toArray(); } /** diff --git a/app/Http/Controllers/API/Admin/ServerController.php b/app/Http/Controllers/API/Admin/ServerController.php index 111d33009..643e67296 100644 --- a/app/Http/Controllers/API/Admin/ServerController.php +++ b/app/Http/Controllers/API/Admin/ServerController.php @@ -47,14 +47,17 @@ class ServerController extends Controller { $this->authorize('server-list', $request->apiKey()); - $servers = Server::paginate(20); - - return Fractal::create() - ->collection($servers) + $servers = Server::paginate(config('pterodactyl.paginate.api.servers')); + $fractal = Fractal::create()->collection($servers) ->transformWith(new ServerTransformer($request)) - ->paginateWith(new IlluminatePaginatorAdapter($servers)) - ->withResourceName('server') - ->toArray(); + ->withResourceName('user') + ->paginateWith(new IlluminatePaginatorAdapter($servers)); + + if (config('pterodactyl.api.allow_includes_on_list') && $request->input('include')) { + $fractal->parseIncludes(explode(',', $request->input('include'))); + } + + return $fractal->toArray(); } /** diff --git a/app/Http/Controllers/API/Admin/UserController.php b/app/Http/Controllers/API/Admin/UserController.php index 5d7ffdf09..15af793d0 100644 --- a/app/Http/Controllers/API/Admin/UserController.php +++ b/app/Http/Controllers/API/Admin/UserController.php @@ -45,13 +45,18 @@ class UserController extends Controller public function index(Request $request) { $this->authorize('user-list', $request->apiKey()); - $users = User::paginate(50); - return Fractal::create()->collection($users) + $users = User::paginate(config('pterodactyl.paginate.api.users')); + $fractal = Fractal::create()->collection($users) ->transformWith(new UserTransformer($request)) ->withResourceName('user') - ->paginateWith(new IlluminatePaginatorAdapter($users)) - ->toArray(); + ->paginateWith(new IlluminatePaginatorAdapter($users)); + + if (config('pterodactyl.api.allow_includes_on_list') && $request->input('include')) { + $fractal->parseIncludes(explode(',', $request->input('include'))); + } + + return $fractal->toArray(); } /** diff --git a/config/pterodactyl.php b/config/pterodactyl.php index bbe93f4da..7d6916891 100644 --- a/config/pterodactyl.php +++ b/config/pterodactyl.php @@ -26,8 +26,24 @@ return [ */ 'paginate' => [ 'frontend' => [ - 'servers' => 15, + 'servers' => env('APP_PAGINATE_FRONT_SERVERS', 15), ], + 'api' => [ + 'nodes' => env('APP_PAGINATE_API_NODES', 25), + 'servers' => env('APP_PAGINATE_API_SERVERS', 25), + 'users' => env('APP_PAGINATE_API_USERS', 25), + ] + ], + + /* + |-------------------------------------------------------------------------- + | API Options + |-------------------------------------------------------------------------- + | + | Configuration options for the API. + */ + 'api' => [ + 'allow_includes_on_list' => env('API_ALLOW_INCLUDE_ON_LIST', false), ], /*