forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetServer.ts
More file actions
52 lines (48 loc) · 1.24 KB
/
getServer.ts
File metadata and controls
52 lines (48 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import http from '@/api/http';
export interface Allocation {
ip: string;
alias: string | null;
port: number;
default: boolean;
}
export interface Server {
id: string;
uuid: string;
name: string;
node: string;
description: string;
allocations: Allocation[];
limits: {
memory: number;
swap: number;
disk: number;
io: number;
cpu: number;
};
featureLimits: {
databases: number;
allocations: number;
};
}
export const rawDataToServerObject = (data: any): Server => ({
id: data.identifier,
uuid: data.uuid,
name: data.name,
node: data.node,
description: data.description ? ((data.description.length > 0) ? data.description : null) : null,
allocations: [{
ip: data.allocation.ip,
alias: null,
port: data.allocation.port,
default: true,
}],
limits: { ...data.limits },
featureLimits: { ...data.feature_limits },
});
export default (uuid: string): Promise<Server> => {
return new Promise((resolve, reject) => {
http.get(`/api/client/servers/${uuid}`)
.then(response => resolve(rawDataToServerObject(response.data.attributes)))
.catch(reject);
});
};