Skip to content

Commit 06422b2

Browse files
committed
fix up API route return
1 parent 9d55e93 commit 06422b2

File tree

6 files changed

+11
-16
lines changed

6 files changed

+11
-16
lines changed

CHANGELOG.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
1414

1515
### Changed
1616
* Support for sub-folders within the `getJavascript()` route for servers.
17-
* 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.
18-
* 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.
19-
* 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.
17+
* **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.
18+
* 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.
2019

2120
### Fixed
2221
* 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)

app/Http/Controllers/API/LocationController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function list(Request $request)
5858
$location->nodes = explode(',', $location->nodes);
5959
}
6060

61-
return $locations;
61+
return $locations->toArray();
6262
}
6363

6464
}

app/Http/Controllers/API/NodeController.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ public function __construct()
6262
*/
6363
public function list(Request $request)
6464
{
65-
$nodes = Models\Node::paginate(50);
66-
return $this->response->paginator($nodes, new NodeTransformer);
65+
return Models\Node::all()->toArray();
6766
}
6867

6968
/**
@@ -170,11 +169,11 @@ public function view(Request $request, $id, $fields = null)
170169
*/
171170
public function allocations(Request $request)
172171
{
173-
$allocations = Models\Allocation::paginate(100);
172+
$allocations = Models\Allocation::all();
174173
if ($allocations->count() < 1) {
175174
throw new NotFoundHttpException('No allocations have been created.');
176175
}
177-
return $this->response->paginator($allocations, new AllocationTransformer);
176+
return $allocations;
178177
}
179178

180179
/**

app/Http/Controllers/API/ServerController.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,28 +132,25 @@ public function view(Request $request, $id)
132132
]
133133
]);
134134

135-
$server->toArray();
136-
137135
// Only return the daemon token if the request is using HTTPS
138136
if ($request->secure()) {
139137
$server->daemon_token = $server->daemonSecret;
140138
}
141139
$server->daemon = json_decode($response->getBody())->{$server->uuid};
142140

143-
return $server;
141+
return $server->toArray();
144142
}
145143

146-
return $server;
144+
return $server->toArray();
147145

148146
} catch (NotFoundHttpException $ex) {
149147
throw $ex;
150148
} catch (\GuzzleHttp\Exception\TransferException $ex) {
151149
// Couldn't hit the daemon, return what we have though.
152-
$server->toArray();
153150
$server->daemon = [
154151
'error' => 'There was an error encountered while attempting to connect to the remote daemon.'
155152
];
156-
return $server;
153+
return $server->toArray();
157154
} catch (\Exception $ex) {
158155
throw new BadRequestHttpException('There was an issue with the fields passed in the request.');
159156
}

app/Http/Controllers/API/ServiceController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct()
4343

4444
public function list(Request $request)
4545
{
46-
return Models\Service::all();
46+
return Models\Service::all()->toArray();
4747
}
4848

4949
public function view(Request $request, $id)

app/Repositories/ServerRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function create(array $data)
7777

7878
// Validate Fields
7979
$validator = Validator::make($data, [
80-
'owner' => 'bail|required|string',
80+
'owner' => 'bail|required',
8181
'name' => 'required|regex:/^([\w -]{4,35})$/',
8282
'memory' => 'required|numeric|min:0',
8383
'swap' => 'required|numeric|min:-1',

0 commit comments

Comments
 (0)