npm library: https://www.npmjs.com/package/deos-client
- Test client network connection
- Persistent user
- Launch app
- Run app (obtain the link for an existing instance)
- Close app
- Get quota
- List active instances
npm install deos-client
Initialize
var { deosClient } = require("deos-client"); // javascript
import { deosClient } from "deos-client"; // typescript
Test network connection
var dc = deosClient(<your-api-key>);
var condition = await dc.testConnection();
console.log(condition);
Persistent user and storage
dc.setExternalUserId(<your-unique-user_id>);
Launch application
try {
// intervalMs is optional, customize the polling interval to check app readiness based on your needs. The default is 1000 ms.
var app = await dc.launch(appName, { intervalMs: 5000 });
if (app.url) {
iframe.src = app.url;
var appInstanceId = app.instance;
}
} catch (error) {
console.error(`code: ${error.response.status}, message: ${error.response.data.message}`);
}
Run application
try {
const url = await dc.run(appInstanceId);
iframe.src = url;
} catch(error) {
console.error(`code: ${error.response.status}, message: ${error.response.data.message}`);
}
Get active instances
try {
const instances = await dc.getAllInstances(appName);
console.log(instances);
} catch (error) {
console.error(`code: ${error.response.status}, message: ${error.response.data.message}`);
}
Delete application
try {
const response = await dc.delete(appInstanceId); // id is returned after launch
} catch (error) {
console.error(`code: ${error.response.status}, message: ${error.response.data.message}`);
}
Get quota for an application
try {
const quota = await dc.getQuota(appName);
console.log(quota);
} catch (error) {
console.error(`code: ${error.response.status}, message: ${error.response.data.message}`);
}