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
* 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.
* 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/servers`](https://pterodactyl.readme.io/v0.5.0/reference#servers) 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 includes an array of all servers the user is set as the owner of.
### 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)

View file

@ -58,7 +58,7 @@ class LocationController extends BaseController
$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)
{
$nodes = Models\Node::paginate(50);
return $this->response->paginator($nodes, new NodeTransformer);
return Models\Node::all()->toArray();
}
/**
@ -170,11 +169,11 @@ class NodeController extends BaseController
*/
public function allocations(Request $request)
{
$allocations = Models\Allocation::paginate(100);
$allocations = Models\Allocation::all();
if ($allocations->count() < 1) {
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
if ($request->secure()) {
$server->daemon_token = $server->daemonSecret;
}
$server->daemon = json_decode($response->getBody())->{$server->uuid};
return $server;
return $server->toArray();
}
return $server;
return $server->toArray();
} catch (NotFoundHttpException $ex) {
throw $ex;
} catch (\GuzzleHttp\Exception\TransferException $ex) {
// Couldn't hit the daemon, return what we have though.
$server->toArray();
$server->daemon = [
'error' => 'There was an error encountered while attempting to connect to the remote daemon.'
];
return $server;
return $server->toArray();
} catch (\Exception $ex) {
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)
{
return Models\Service::all();
return Models\Service::all()->toArray();
}
public function view(Request $request, $id)

View file

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