Skip to main content

Making a Commit

application.commit() is a method that allows you to commit a file to your application.
const { DsCloudAPI } = require("@dscloud/sdkapi");
const api = new DsCloudAPI("Your API Key");

const application = await api.getApplication("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 an Upload

application.create() is a method that allows you to upload an application to Ds Cloud.
const { DsCloudAPI } = require("@dscloud/sdkapi");
const api = new DsCloudAPI("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 (dscloud.pt): 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.
aaa