Uploading a new application
api.applications.create(file) uploads a zip and creates a brand-new application. The file argument is either a local file path or a Buffer.
import { SquareCloudAPI } from "@squarecloud/api";
import { join } from "node:path";
const api = new SquareCloudAPI(process.env.SQUARE_API_KEY!);
const result = await api.applications.create(join(__dirname, "my-app.zip"));
console.log(result.id); // newly created application ID
console.log(result.name); // display name
console.log(result.lang); // language slug (e.g. "javascript")
console.log(result.ram); // allocated RAM in MB
The zip must contain at least:
- Main file — entry point of your application
- Dependencies file —
package.json, requirements.txt, etc.
squarecloud.app — configuration file with name, description, main file, version, etc. See the config file guide
Committing files to an existing application
app.commit(file, fileName?) uploads files into an already-deployed application. Pass a zip to replace multiple files at once, or a single file to update just that one.
| Parameter | Type | Description |
|---|
file | string | Buffer | Local file path or Buffer content |
fileName | string? | Destination file name. Defaults to "commit.zip" |
const content = Buffer.from("console.log('hello')\n");
await app.commit(content, "index.js");
import { readFile } from "node:fs/promises";
const zip = await readFile("./dist.zip");
await app.commit(zip, "dist.zip");
import { join } from "node:path";
const filePath = join(__dirname, "index.js");
await app.commit(filePath, "index.js");
In v3 commit() accepted a third restart argument. In v4 the third parameter has been removed — use app.restart() after the commit if you need a restart.
await app.commit(zip, "dist.zip");
await app.restart();