-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathcreateData_Private.js
More file actions
53 lines (44 loc) · 1.66 KB
/
createData_Private.js
File metadata and controls
53 lines (44 loc) · 1.66 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
53
const axios = require("axios");
const Config = require('./config.json');
const fs = require("fs");
const path = require("path");
// Private Node Configuration:
const PRIVATE_NODE_LOCATION = [43];
global.privateNodeLocations = PRIVATE_NODE_LOCATION;
let ServerTypes = {};
const createParams = (ServerName, ServerType, UserID) => {
return ServerTypes[ServerType].createServer(ServerName, UserID, PRIVATE_NODE_LOCATION);
};
const createServer = (ServerData) => {
return axios({
url: Config.Pterodactyl.hosturl + "/api/application/servers",
method: "POST",
followRedirect: true,
maxRedirects: 5,
headers: {
Authorization: "Bearer " + Config.Pterodactyl.apikey,
"Content-Type": "application/json",
Accept: "Application/vnd.pterodactyl.v1+json"
},
data: ServerData,
});
};
async function initialStart() {
try {
const files = (await fs.promises.readdir("./create-private/")).filter((f) => f.endsWith(".js"));
for (const file of files) {
const fullPath = path.resolve("./create-private/", file);
delete require.cache[require.resolve(fullPath)];
const module = require(fullPath);
ServerTypes[file.replace(".js", "")] = module;
}
} catch (Error) {
console.error("Error reading files:", Error);
}
}
module.exports = {
serverTypes: ServerTypes, // Types of servers property.
createParams: createParams, // Create server parameters with server name and user ID.
createServer: createServer, // Create server function.
initialStart: initialStart, // Initial start function.
};