Perishable demo app
Deploy the perishable demo workload.
deployPerishable.js
1
import { createZip } from "stackmachine";
2
3
console.log("Uploading file...");
4
5
const zip = await createZip({
6
"index.php":
7
"<html><body><h1>This app will perish in 2 hours</h1></body></html>",
8
});
9
const uploadUrl = await client.files.upload(zip, {
10
onProgress: ({ percent }) => {
11
console.log("Uploading files... ", percent * 100, "%");
12
},
13
});
14
15
const deployment = await client.deployments.create({
16
appName: "perishable-app",
17
owner: "stackmachine",
18
uploadUrl: uploadUrl,
19
perishAt: "PT2H", // 2 hours (ISO 8601 duration)
20
});
21
22
console.log("Deploying app...");
23
let startTime = new Date();
24
console.log("Waiting for the app to be built...");
25
const appVersion = await deployment.wait({
26
onProgress: ({ kind, message, datetime, stream }) => {
27
console.log(datetime, stream, kind, message);
28
},
29
});
30
console.log("App built!", appVersion);
31
console.log(appVersion.app.willPerishAt);
32
console.log("Time taken:", new Date().getTime() - startTime.getTime(), "ms");
Source: stackmachine/sdks examples.