diff --git a/README.md b/README.md index 83090f0..7f970c9 100644 --- a/README.md +++ b/README.md @@ -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().then((response) => { // and now functions with response for example "consle.log(response)" or what you want }) @@ -54,7 +54,7 @@ admin.FUNCTIONNAME().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: @@ -62,7 +62,7 @@ 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. -

Example: 1.2.4 = Release one, function update two, bug fix update two.

+

Example: 1.5.1 = Release one, function update two, bug fix update two.

-------------------------------------------------------------------------------------------------- Disclaimer diff --git a/application/ApplicationRequest.js b/application/ApplicationRequest.js index 6ded29f..57b8452 100644 --- a/application/ApplicationRequest.js +++ b/application/ApplicationRequest.js @@ -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: { @@ -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); @@ -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 = ''; @@ -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) { @@ -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] } } diff --git a/application/index.js b/application/index.js index a23014f..7cf0e15 100644 --- a/application/index.js +++ b/application/index.js @@ -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, @@ -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; } }); diff --git a/application/methods/createServer.js b/application/methods/createServer.js index e44841d..74cfa9b 100644 --- a/application/methods/createServer.js +++ b/application/methods/createServer.js @@ -1,3 +1,4 @@ +const { version } = require('discord.js'); const req = require('../ApplicationRequest.js'); /** * @param {String} Version Version of the server to use @@ -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, @@ -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 diff --git a/application/methods/getAllServers.js b/application/methods/getAllServers.js index 9fce5b3..d0f19a0 100644 --- a/application/methods/getAllServers.js +++ b/application/methods/getAllServers.js @@ -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); } diff --git a/application/methods/getUserQuery.js b/application/methods/getUserQuery.js new file mode 100644 index 0000000..2816f0c --- /dev/null +++ b/application/methods/getUserQuery.js @@ -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; \ No newline at end of file diff --git a/client/index.js b/client/index.js index b5698d0..5212682 100644 --- a/client/index.js +++ b/client/index.js @@ -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; } }); diff --git a/package.json b/package.json index 99f8241..2461707 100644 --- a/package.json +++ b/package.json @@ -1,35 +1,38 @@ { - "_from": "nodeactyl-v1-support@^1.5.9", - "_id": "nodeactyl-v1-support@1.5.9", + "_args": [ + [ + "nodeactyl-v1-support@1.5.1" + ] + ], + "_from": "nodeactyl-v1-support@1.5.1", + "_id": "nodeactyl-v1-support@1.5.1", "_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": "nodeactyl-v1-support@1.5.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" }, @@ -45,5 +48,5 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, - "version": "1.5.9" + "version": "1.5.1" }