@cere-ddc-sdk/web-loader
v0.2.0
Published
The tool to upload HTML apps to the DDC
Keywords
Readme
Web loader
This package allows to upload HTML apps to the DDC.
Uploading an HTML app
npm i @cere-ddc-sdk/ddc-client @cere-ddc-sdk/web-loader -DA deploy script example:
import { uploadWebApp } from '@cere-ddc-sdk/web-loader';
import { DdcClient, TESTNET } from '@cere-ddc-sdk/ddc-client';
const ddcClient = await DdcClient.buildAndConnect(
{
clusterAddress: Number(process.env.CLUSTER_ADDRESS),
smartContract: TESTNET,
},
process.env.USER_MNEMONIC,
);
const result = await uploadWebApp(ddcClient, {
folder: distFolder,
appId: process.env.DDC_APP_ID,
bucketId: process.env.BUCKET_ID,
});Used variables:
process.env.USER_MNEMONIC, how to set up a userprocess.env.BUCKET_IDis a bucket id, refer to this guide to find out how to create a bucketprocess.env.CLUSTER_ADDRESScan be found hereprocess.env.DDC_APP_IDthisappIdcould be omitted for the first upload, but it will be required if you want to update the already uploaded app. The target app URL will look like<cdn node URL>/ddc/buc/<bucket id>/file/<app id>. I.e.appIdis any unique, within a bucket, string.
The script result:
// the script above will return an object
type Result = {
url: string; // an URL for the uploded app
appId: string; // if the appId was omitted, one can use this value for the next updates
}