Making a commit

application.commit() is a method that allows you to commit a file to your application.

  • Using Buffer

  • Using Absolute Path

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 commit
const fileContent = Buffer.from("Your file content");
const fileName = "file.txt";

// Optionally, set whether the application should restart after the commit
const shouldRestart = true;

// Perform the commit operation
const success = await application.commit(fileContent, fileName, shouldRestart);

// Handle the result accordingly
if (success) {
    console.log(`File "${fileName}" committed successfully.`);
} else {
    console.error(`Failed to commit file "${fileName}".`);
}

Making a upload

application.create() is a method that allows you to upload a application to Square Cloud.

const { SquareCloudAPI } = require("@squarecloud/api");
const api = new SquareCloudAPI("Your API Key");

// Specify the content and name of the zip file you want to upload
const { join } = require("node:path");
const fileName = "application.zip";
const filePath = join(__dirname, fileName);

// Perform the upload operation
const success = await api.applications.create(filePath);

// Handle the result accordingly
if (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.