Initialize the client
Create an Appaloft client inside a server, worker, or internal tool. Auth material comes from your trusted environment.
import { createAppaloftClient } from "@appaloft/sdk";
export const appaloft = createAppaloftClient({
baseUrl: process.env.APPALOFT_BASE_URL ?? "https://app.appaloft.com",
auth: () => ({
kind: "deploy-token",
token: process.env.APPALOFT_TOKEN!,
}),
headers: { "x-app-name": "internal-ops" },
});
Create a project
Facades are grouped by operation area. Project operations live under the plural projects group.
const created = await appaloft.projects.create({
body: {
name: "acme-web",
description: "Marketing site and API workers",
},
});
if (!created.ok) {
throw new Error(created.error.message);
}
console.log("project", created.data);
List and inspect
Query operations use the same ok/error result shape, which makes Appaloft status easy to embed in your own dashboard.
const projects = await appaloft.projects.list();
if (projects.ok) {
for (const project of projects.data as unknown[]) {
console.log(project);
}
}
const resource = await appaloft.resources.show({
pathParams: { resourceId: "res_123" },
});
Handle errors
Do not parse error strings. Use code, category, and retryable to decide whether to show guidance, retry, or escalate.
const result = await appaloft.deployments.create({
body: {
projectId: "prj_123",
resourceId: "res_123",
source: { kind: "git", ref: "main" },
},
});
if (!result.ok) {
if (result.error.retryable) {
console.warn("retry later", result.error.code);
} else {
console.error(result.error.category, result.error.message);
}
}