Tiiny demo
Tiiny integration sample.
tiinyBlocked.js
1
import { createZip } from "stackmachine";
2
3
async function execWasmerDeploy(deployPath, subdomain) {
4
try {
5
const zip = await createZip(deployPath);
6
7
const upload = await client.files.upload(zip);
8
9
const deployment = await client.deployments.create({
10
appName: subdomain,
11
owner: "tiinyhost",
12
uploadUrl: upload,
13
domains: [`${subdomain}-syrus.wasmer.app`],
14
});
15
console.log(upload);
16
console.log(`Deploy: ${deployPath}`);
17
console.debug(`App successfully deployed: ${subdomain}`);
18
console.log("Deploying app...");
19
let startTime = new Date();
20
console.log("Waiting for the app to be built...");
21
const app = await deployment.wait({
22
onProgress: ({ kind, message, datetime, stream }) => {
23
console.log(datetime, stream, kind, message);
24
},
25
});
26
console.log("App built!", app);
27
console.log(app.kind);
28
console.log(
29
"Time taken:",
30
new Date().getTime() - startTime.getTime(),
31
"ms",
32
);
33
} catch (error) {
34
console.log(`Error deploying app: ${error}`);
35
throw new Error("Wasmer deploy error: " + error);
36
}
37
}
38
39
execWasmerDeploy(
40
{ "index.php": "<html><body><h1>Hello World!</h1></body></html>" },
41
"test-my-app-syrus9",
42
);
Source: stackmachine/sdks examples.