fix up API route return

This commit is contained in:
Dane Everitt 2016-10-07 14:26:50 -04:00
parent 9d55e93e9e
commit 06422b2055
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
6 changed files with 11 additions and 16 deletions

View File

@ -14,9 +14,8 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
### Changed ### Changed
* Support for sub-folders within the `getJavascript()` route for servers. * Support for sub-folders within the `getJavascript()` route for servers.
* API route for [`/api/users`](https://pterodactyl.readme.io/v0.5.0/reference#users) now returns a non-paginated result set, and is a single array. * **ALL** API routes previously returning paginated result sets, or result sets nested inside a descriptive block (e.g. `servers:`) have been changed to return a single array of all associated items. Please see the [updated documentation](https://pterodactyl.readme.io/v0.5.0/reference) for how this change might effect your API use.
* API route for [`/api/users/:id`](https://pterodactyl.readme.io/v0.5.0/reference#single-user) now returns a single array including an array of all servers the user is set as the owner of. * API route for [`/api/users/:id`](https://pterodactyl.readme.io/v0.5.0/reference#single-user) now includes an array of all servers the user is set as the owner of.
* API route for [`/api/servers`](https://pterodactyl.readme.io/v0.5.0/reference#servers) now returns a non-paginated result set, and is a single array.
### Fixed ### Fixed
* File manager would do multiple up-down-up-down loading actions if you escaped renaming a file. Fixed the binding issue. [#122](https://github.com/Pterodactyl/Panel/issues/122) * File manager would do multiple up-down-up-down loading actions if you escaped renaming a file. Fixed the binding issue. [#122](https://github.com/Pterodactyl/Panel/issues/122)

View File

@ -58,7 +58,7 @@ class LocationController extends BaseController
$location->nodes = explode(',', $location->nodes); $location->nodes = explode(',', $location->nodes);
} }
return $locations; return $locations->toArray();
} }
} }

View File

@ -62,8 +62,7 @@ class NodeController extends BaseController
*/ */
public function list(Request $request) public function list(Request $request)
{ {
$nodes = Models\Node::paginate(50); return Models\Node::all()->toArray();
return $this->response->paginator($nodes, new NodeTransformer);
} }
/** /**
@ -170,11 +169,11 @@ class NodeController extends BaseController
*/ */
public function allocations(Request $request) public function allocations(Request $request)
{ {
$allocations = Models\Allocation::paginate(100); $allocations = Models\Allocation::all();
if ($allocations->count() < 1) { if ($allocations->count() < 1) {
throw new NotFoundHttpException('No allocations have been created.'); throw new NotFoundHttpException('No allocations have been created.');
} }
return $this->response->paginator($allocations, new AllocationTransformer); return $allocations;
} }
/** /**

View File

@ -132,28 +132,25 @@ class ServerController extends BaseController
] ]
]); ]);
$server->toArray();
// Only return the daemon token if the request is using HTTPS // Only return the daemon token if the request is using HTTPS
if ($request->secure()) { if ($request->secure()) {
$server->daemon_token = $server->daemonSecret; $server->daemon_token = $server->daemonSecret;
} }
$server->daemon = json_decode($response->getBody())->{$server->uuid}; $server->daemon = json_decode($response->getBody())->{$server->uuid};
return $server; return $server->toArray();
} }
return $server; return $server->toArray();
} catch (NotFoundHttpException $ex) { } catch (NotFoundHttpException $ex) {
throw $ex; throw $ex;
} catch (\GuzzleHttp\Exception\TransferException $ex) { } catch (\GuzzleHttp\Exception\TransferException $ex) {
// Couldn't hit the daemon, return what we have though. // Couldn't hit the daemon, return what we have though.
$server->toArray();
$server->daemon = [ $server->daemon = [
'error' => 'There was an error encountered while attempting to connect to the remote daemon.' 'error' => 'There was an error encountered while attempting to connect to the remote daemon.'
]; ];
return $server; return $server->toArray();
} catch (\Exception $ex) { } catch (\Exception $ex) {
throw new BadRequestHttpException('There was an issue with the fields passed in the request.'); throw new BadRequestHttpException('There was an issue with the fields passed in the request.');
} }

View File

@ -43,7 +43,7 @@ class ServiceController extends BaseController
public function list(Request $request) public function list(Request $request)
{ {
return Models\Service::all(); return Models\Service::all()->toArray();
} }
public function view(Request $request, $id) public function view(Request $request, $id)

View File

@ -77,7 +77,7 @@ class ServerRepository
// Validate Fields // Validate Fields
$validator = Validator::make($data, [ $validator = Validator::make($data, [
'owner' => 'bail|required|string', 'owner' => 'bail|required',
'name' => 'required|regex:/^([\w -]{4,35})$/', 'name' => 'required|regex:/^([\w -]{4,35})$/',
'memory' => 'required|numeric|min:0', 'memory' => 'required|numeric|min:0',
'swap' => 'required|numeric|min:-1', 'swap' => 'required|numeric|min:-1',