@squarecloud/api
Advanced tools
@@ -8,3 +8,2 @@ import { APIResponse, RawUserData } from './typings'; | ||
| constructor(apiKey: string); | ||
| private testApiKey; | ||
| private fetch; | ||
@@ -11,0 +10,0 @@ user(id?: string, options?: RequestInit): Promise<RawUserData>; |
+1
-11
@@ -21,12 +21,3 @@ "use strict"; | ||
| this.apiKey = apiKey; | ||
| this.testApiKey(); | ||
| } | ||
| async testApiKey() { | ||
| try { | ||
| await this.fetch('user'); | ||
| } | ||
| catch { | ||
| throw new SquareCloudAPIError('INVALID_API_KEY'); | ||
| } | ||
| } | ||
| async fetch(path, options = {}) { | ||
@@ -38,4 +29,3 @@ options.headers = { | ||
| options.method = options.method || 'GET'; | ||
| const data = await fetch('https://api.squarecloud.app/v1/public/' + path, options) | ||
| .then((r) => r.json()); | ||
| const data = await fetch('https://api.squarecloud.app/v1/public/' + path, options).then((r) => r.json()); | ||
| if (data.status === 'error') { | ||
@@ -42,0 +32,0 @@ throw new SquareCloudAPIError(data.code); |
+1
-2
| { | ||
| "name": "@squarecloud/api", | ||
| "version": "1.1.7", | ||
| "version": "1.1.8", | ||
| "description": "A JavaScript Wrapper for SquareCloud API", | ||
@@ -30,3 +30,2 @@ "main": "lib/index.js", | ||
| "dependencies": { | ||
| "axios": "^1.1.3", | ||
| "form-data": "^4.0.0", | ||
@@ -33,0 +32,0 @@ "zod": "^3.19.1" |
+22
-23
@@ -16,3 +16,2 @@ # **Installation** | Instalação | ||
| # **Setting Up** | Configurando | ||
@@ -23,5 +22,5 @@ | ||
| ```js | ||
| import { SquareCloudAPI } from '@squarecloud/api' // JavaScript: const { SquareCloudAPI } = require('@squarecloud/api') | ||
| import { SquareCloudAPI } from '@squarecloud/api'; // JavaScript: const { SquareCloudAPI } = require('@squarecloud/api') | ||
| const api = new SquareCloudAPI('Your API Key') | ||
| const api = new SquareCloudAPI('Your API Key'); | ||
| ``` | ||
@@ -33,7 +32,7 @@ | ||
| // If the ID is not provided it will get your own informations | ||
| const user = await api.getUser('User Discord ID') | ||
| const user = await api.getUser('User Discord ID'); | ||
| // To get private properties you have to check if you have access: | ||
| if (user.hasAccess()) { | ||
| console.log(user.applications) | ||
| console.log(user.applications); | ||
| } | ||
@@ -49,6 +48,6 @@ ``` | ||
| ```js | ||
| const user = await api.getUser() | ||
| const user = await api.getUser(); | ||
| // Through the array from the user (Only available if you have access to it) | ||
| const application = user.applications[0] | ||
| // Through the collection from the user (Only available if you have access to it) | ||
| const application = user.applications.get('Application Id'); | ||
| ``` | ||
@@ -60,3 +59,3 @@ | ||
| // Using the Application ID | ||
| const application = await api.getApplication('ID') | ||
| const application = await api.getApplication('Application Id'); | ||
| ``` | ||
@@ -69,6 +68,6 @@ | ||
| ```js | ||
| const application = await api.getApplication('ID') | ||
| const application = await api.getApplication('Application Id'); | ||
| // Returns a bunch of info about the current status of the app | ||
| application.getStatus() | ||
| application.getStatus(); | ||
| ``` | ||
@@ -79,7 +78,7 @@ | ||
| ```js | ||
| const application = await api.getApplication('ID') | ||
| const application = await api.getApplication('Application Id'); | ||
| // If `true` it will get the full logs url | ||
| // If `false` or blank it will get only the recent logs string | ||
| application.getLogs(true) | ||
| application.getLogs(true); | ||
| ``` | ||
@@ -92,11 +91,11 @@ | ||
| ```js | ||
| const application = await api.getApplication('ID') | ||
| const application = await api.getApplication('Application Id'); | ||
| // Every single method will return `true` if it is successfuly executed | ||
| application.start() | ||
| application.start(); | ||
| application.stop() | ||
| application.stop(); | ||
| application.restart() | ||
| application.restart(); | ||
| ``` | ||
@@ -107,6 +106,6 @@ | ||
| ```js | ||
| const application = await api.getApplication('ID') | ||
| const application = await api.getApplication('Application Id'); | ||
| // Generates a backup and returns its download url | ||
| application.backup() | ||
| application.backup(); | ||
| ``` | ||
@@ -117,6 +116,6 @@ | ||
| ```js | ||
| const application = await api.getApplication('ID') | ||
| const application = await api.getApplication('Application Id'); | ||
| // Deletes your whole application | ||
| application.delete() | ||
| application.delete(); | ||
| ``` | ||
@@ -129,3 +128,3 @@ | ||
| const application = await api.getApplication('ID') | ||
| const application = await api.getApplication('Application Id') | ||
@@ -137,3 +136,3 @@ // Commits a file change to your application | ||
| // You can use Buffers too: | ||
| application.commit(<Buffer>, 'index', '.js') | ||
| application.commit(<Buffer>, 'index.js') | ||
| ``` |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
2
-33.33%7
-12.5%48929
-0.32%977
-1.11%127
-0.78%- Removed
- Removed
- Removed
- Removed