deos-client
v1.0.22
Published
npm library: https://www.npmjs.com/package/deos-client [![N|Solid](https://avatars.githubusercontent.com/u/6078720?s=50&v=4)](https://nodesource.com/products/nsolid)
Downloads
360
Readme
Deos Client
npm library: https://www.npmjs.com/package/deos-client
Features
- Test client network connection
- Persistent user
- Launch app
- Run app (obtain the link for an existing instance)
- Close app
- Get quota
- List active instances
Installation
npm install deos-client
Examples
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 }, [{"env_var_name": "foo", "env_var_value": "bar"}], "./path/to/excecutable.sh");
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}`);
}
Retrieve the available turbos for a specific application.
try {
const turbos = await dc.getTurbos(appName);
console.log(turbos);
} catch (error) {
console.error(`code: ${error.response.status}, message: ${error.response.data.message}`);
}