Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxTale-Labs authored Jun 2, 2021
1 parent ea3ef8b commit 057a333
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 36 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ admin.login("YOUR HOST", "YOUR ADMIN API KEY", (logged_in, msg) => {
```
And then you can use any funtion you want:
```javascript
client.FUNCTIONNAME('server_id').then((response) => {
client.FUNCTIONNAME(<NEEDED VALUES>).then((response) => {
// and now functions with response for example "consle.log(response)" or what you want
})

Expand All @@ -54,15 +54,15 @@ admin.FUNCTIONNAME(<NEEDED VALUES>).then((response) => {
})
```

NOTE: You can use every function from original nodeactyl: https://docs.nodeactyl.dev/
NOTE: You can use every function from original nodeactyl: https://docs.nodeactyl.xyz/
---------------------------------------------------------------------------------------------------

How our Version numbers work:
---------------------------------------------------------------------------------------------------
- The first number means the release number.
- The second number means function release.
- The third number means Bug fix version code.
<p>Example: 1.2.4 = Release one, function update two, bug fix update two.</p>
<p>Example: 1.5.1 = Release one, function update two, bug fix update two.</p>
--------------------------------------------------------------------------------------------------

Disclaimer
Expand Down
19 changes: 12 additions & 7 deletions application/ApplicationRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Request {
const err = createError(request, error, data);
if (err) throw err;
});
} else if (request == "GetUserInfo" || request == "GetAllUsers") {
} else if (request == "GetUserInfo" || request == "GetAllUsers" || request == "GetAllUsersPagination") {
return axios.default.get(splitted, {
maxRedirects: 5,
headers: {
Expand All @@ -48,10 +48,10 @@ class Request {
'Accept': 'Application/vnd.pterodactyl.v1+json',
},
}).then(response => {
if (request == 'GetAllUsers') {
if (request == 'GetAllUsers' || request == "GetAllUsersPagination") {
return response.data.data;
} else if (request == 'GetUserInfo') {
return response.data.data;
return response.data.attributes;
}
}).catch(error => {
const err = createError(request, error, data);
Expand Down Expand Up @@ -179,7 +179,7 @@ class Request {
}
// Third arg is nullable
patchRequest(request, data, _data) {
const URL = getUrl(request, this.host, data); // data is nullable
const URL = getUrl(request, this.host, data, _data); // data is nullable

var splittedURL = URL.split('/')
var splitted = '';
Expand Down Expand Up @@ -276,11 +276,16 @@ const users = ['CreateUser', 'GetAllUsers'];
const user = ['EditUser', 'DeleteUser', 'GetUserInfo'];
const nodes = ['GetAllNodes', 'CreateNode'];
const node = ['GetNodeInfo', 'DeleteNode'];
function getUrl(request, host, data) { // _data = nullable
function getUrl(request, host, data, _data) { // _data = nullable
if (user.indexOf(request) > -1) {
return host + '/api/application/users/' + data;
if (_data != null) {
return host + '/api/application/users/' + _data;
} else {
return host + '/api/application/users/' + data;
}
}
else if (server.indexOf(request) > -1) {
if (data != undefined) return host + '/api/application/servers?page=' + data;
return host + '/api/application/servers';
}
else if (server.indexOf(request) > -1) {
Expand Down Expand Up @@ -313,7 +318,7 @@ function getUrl(request, host, data) { // _data = nullable
else if(request == 'GetAllUsersPagination') {
return host + '/api/application/users?page=' + data;
} else if (request == "GetAllAllocations") {
return host + "/api/application/nodes/" + data + "/allocations"
return host + "/api/application/nodes/" + data[0] + "/allocations?page=" + data[1]
}
}

Expand Down
9 changes: 5 additions & 4 deletions application/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ function login(HOST, KEY, callback) {

process.env.APPLICATION_NODEACTYL_HOST = HOST;
process.env.APPLICATION_NODEACTYL_KEY = KEY;

console.log(HOST + '/api/application/users')
axios.get(HOST + '/api/application/users', {
responseEncoding: 'utf8',
maxRedirects: 5,
Expand All @@ -48,15 +50,14 @@ function login(HOST, KEY, callback) {
}).then(function(response) {
if (response.status == 404) {
callback(false, 'API Key is not valid! (Application)');
}
else {
} else {
callback(true);
}
}).catch(error => {
console.log(error)
if (error.response.status == 403) {
callback(false, 'API Key is not valid! (Application)');
}
else {
} else {
throw error;
}
});
Expand Down
48 changes: 43 additions & 5 deletions application/methods/createServer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { version } = require('discord.js');
const req = require('../ApplicationRequest.js');
/**
* @param {String} Version Version of the server to use
Expand All @@ -17,21 +18,21 @@ const req = require('../ApplicationRequest.js');
*
* @yields Object (refer to docs for schema);
*/
function createServer(allocationID, Version, NameOfServer, OwnerID, EggID, DockerImage,
function createServer(allocationID, Version, NameOfServer, Description, OwnerID, EggID, DockerImage,
StartupCmd, RAM, Swap, Disk, IO, CPU,
AmountOfDatabases, AmountOfAllocations, backups, node) {
const data = makeData(allocationID, Version, NameOfServer, OwnerID, EggID, DockerImage, StartupCmd, RAM, Swap, Disk, IO, CPU, AmountOfDatabases, AmountOfAllocations, backups, node);
const data = makeData(allocationID, Version, NameOfServer, Description, OwnerID, EggID, DockerImage, StartupCmd, RAM, Swap, Disk, IO, CPU, AmountOfDatabases, AmountOfAllocations, backups, node);
const Req = new req(process.env.APPLICATION_NODEACTYL_HOST, process.env.APPLICATION_NODEACTYL_KEY);
return Req.postRequest('CreateServer', data, null);
}

function makeData(allocationID, Version, NameOfServer, OwnerID, EggID, DockerImage,
function makeData(allocationID, Version, NameOfServer, Description, OwnerID, EggID, DockerImage,
StartupCmd, RAM, Swap, Disk, IO, CPU,
AmountOfDatabases, AmountOfAllocations, backups, node) {
return {
'name': NameOfServer,
'user': OwnerID,
'description': '',
'description': Description,
"node": node,
'egg': EggID,
'docker_image': DockerImage,
Expand Down Expand Up @@ -59,7 +60,44 @@ function makeData(allocationID, Version, NameOfServer, OwnerID, EggID, DockerIma
'INSTALL_REPO': Version,
"BOT_JS_FILE": "index.js",
"AUTO_UPDATE": false,
"USER_UPLOAD": true
"USER_UPLOAD": true,
"BOT_PY_FILE": "bot.py",
"REQUIREMENTS_FILE": "python requirements.txt",
"BEDROCK_VERSION": version,
"LD_LIBRARY_PATH": ".",
"SERVERNAME": NameOfServer,
"GAMEMODE": "survival",
"DIFFICULTY": "easy",
"CHEATS": "false",
"BUILD_TYPE": "recommended",
"PGDATABASE": ".",
"PGUSER": ".",
"PGROOT": ".",
"PGPASSWORD": ".",
"MINECRAFT_VERSION": Version,
"NUKKIT_VERSION": "latest",
"JARFILE": "bot.jar",
"VERSION": "latest",
"QUERY_PORT": "10101",
"FILE_PORT": "303030",
"SERVER_MOTD": "TeaSpeak\n\rHosted on PureNodes!",
"LD_LIBRARY_PATH": "./libs/",
"LD_PRELOAD": "./libs/libjemalloc.so.2",
"SERVER_JARFILE": "server.jar",
"MATCH": "ts3-manager-linux-x64",
"GITHUB_PACKAGE": "joni1802/ts3-manager",
"SERVER_VERSION": "latest",
"RELEASE_VERSION": "latest",
"CHANNEL_NAME": ".",
"CHANNEL_OWNER": ".",
"BOT_OAUTH_TOKEN": ".",
"USER_OAUTH_TOKEN": ".",
"BOT_TWITCH_USERNAME": ".",
"WEBPANEL_USERNAME": ".",
"WEBPANEL_PASSWORD": ".",
"YOUTUBE_API_KEY": ".",
"DISCORD_BOT_TOKEN": ".",
"PMMP_VERSION": "latest"
},
"allocation": {
"default": allocationID
Expand Down
3 changes: 2 additions & 1 deletion application/methods/getAllServers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const req = require('../ApplicationRequest.js');

function getAllServers() {
function getAllServers(page) {
const Req = new req(process.env.APPLICATION_NODEACTYL_HOST, process.env.APPLICATION_NODEACTYL_KEY);
if (page != undefined) return Req.getRequest('GetAllServers', page);
return Req.getRequest('GetAllServers', null);
}

Expand Down
11 changes: 11 additions & 0 deletions application/methods/getUserQuery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const req = require('../ApplicationRequest.js');
/**
* @param {String} email Specify a page, leave blank if you dont want to paginate
*/

function getUserQuery(email) {
const Req = new req(process.env.APPLICATION_NODEACTYL_HOST, process.env.APPLICATION_NODEACTYL_KEY);
return Req.getRequest('UserQuery', email);
}

module.exports = getUserQuery;
6 changes: 2 additions & 4 deletions client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,13 @@ function login(HOST, KEY, callback) {
}).then(function(response) {
if (response.status == 404) {
callback(false, 'API Key is not valid! (Application)');
}
else {
} else {
callback(true);
}
}).catch(error => {
if (error.response.status == 403) {
callback(false, 'API Key is not valid! (Application)');
}
else {
} else {
throw error;
}
});
Expand Down
27 changes: 15 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
{
"_from": "nodeactyl-v1-support@^1.5.9",
"_id": "[email protected]",
"_args": [
[
"[email protected]"
]
],
"_from": "[email protected]",
"_id": "[email protected]",
"_inBundle": false,
"_integrity": "sha512-DJiQ95ZcRalW5PyH/VGatyE+IGY5xso4T4x4k78lc6u/Lh89lKkVOPFyKgrYPqmtXWu/vNp5RA1TLoAtPaAtaQ==",
"_location": "/nodeactyl-v1-support",
"_phantomChildren": {},
"_requested": {
"type": "range",
"type": "version",
"registry": true,
"raw": "nodeactyl-v1-support@^1.5.9",
"raw": "[email protected].1",
"name": "nodeactyl-v1-support",
"escapedName": "nodeactyl-v1-support",
"rawSpec": "^1.5.9",
"rawSpec": "1.5.1",
"saveSpec": null,
"fetchSpec": "^1.5.9"
"fetchSpec": "1.5.1"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/nodeactyl-v1-support/-/nodeactyl-v1-support-1.4.8.tgz",
"_shasum": "e83e5a31c61867850673c4a0428d3009d4b73587",
"_spec": "nodeactyl-v1-support@^1.5.9",
"_where": "C:\\Users\\engin\\Desktop\\Development\\RedHost Client",
"_shasum": "7ed937e8e7fc350fc1adc9e5cff2cbc3ac6d0916",
"_spec": "1.5.1",
"_where": "C:\\Users\\Engin\\Desktop\\Development\\Terra-X\\client",
"author": {
"name": "EiskalterFreund"
},
"bugs": {
"url": "https://github.com/EiskalterFreund/Nodeactyl-v1-support/"
},
"bundleDependencies": false,
"dependencies": {
"axios": "^0.21.0"
},
Expand All @@ -45,5 +48,5 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "1.5.9"
"version": "1.5.1"
}

0 comments on commit 057a333

Please sign in to comment.