application.commit() is a method that allows you to commit a file to your application.
Copy
Ask AI
const { SquareCloudAPI } = require("@squarecloud/api");const api = new SquareCloudAPI("Your API Key");const application = await api.applications.get("Application ID");// Specify the content and name of the file you want to commitconst fileContent = Buffer.from("Your file content");const fileName = "file.txt";// Perform the commit operationconst success = await application.commit(fileContent, fileName);// Handle the result accordinglyif (success) { console.log(`File "${fileName}" committed successfully.`);} else { console.error(`Failed to commit file "${fileName}".`);}
Copy
Ask AI
const { SquareCloudAPI } = require("@squarecloud/api");const api = new SquareCloudAPI("Your API Key");const application = await api.applications.get("Application ID");// Specify the content and name of the file you want to commitconst fileContent = Buffer.from("Your file content");const fileName = "file.txt";// Perform the commit operationconst success = await application.commit(fileContent, fileName);// Handle the result accordinglyif (success) { console.log(`File "${fileName}" committed successfully.`);} else { console.error(`Failed to commit file "${fileName}".`);}
Copy
Ask AI
const { SquareCloudAPI } = require("@squarecloud/api");const api = new SquareCloudAPI("Your API Key");const application = await api.applications.get("Application ID");// Specify the content and name of the file you want to commitconst { join } = require("node:path");const fileName = "file.txt";const filePath = join(__dirname, fileName);// Optionally, set whether the application should restart after the commitconst shouldRestart = true;// Perform the commit operationconst success = await application.commit(filePath, fileName, shouldRestart);// Handle the result accordinglyif (success) { console.log(`File "${fileName}" committed successfully.`);} else { console.error(`Failed to commit file "${fileName}".`);}
application.create() is a method that allows you to upload a application to Square Cloud.
Copy
Ask AI
const { SquareCloudAPI } = require("@squarecloud/api");const api = new SquareCloudAPI("Your API Key");// Specify the content and name of the zip file you want to uploadconst { join } = require("node:path");const fileName = "application.zip";const filePath = join(__dirname, fileName);// Perform the upload operationconst success = await api.applications.create(filePath);// Handle the result accordinglyif (success) { console.log(`Application uploaded successfully.`, success); // Return the application uploaded information (id, tag, description, etc.)} else { console.error(`Failed to upload application.`);}
Remember that to upload an application you need a zip that contains (at least) the following files::
Main file: responsible for starting your application
Dependencies file: contains information about which dependencies are necessary
Configuration file (squarecloud.app): a configuration file specifying the
name,
description, main file name, version, etc. To learn more about the
configuration file, take a look at this guide.