0.14.4 • Published 2 months ago

@siafoundation/renterd-js v0.14.4

Weekly downloads
-
License
MIT
Repository
-
Last release
2 months ago

renterd-js

SDK for interacting with renterd.

Installation

npm install @siafoundation/renterd-js

Usage

import { Bus, Worker, Autopilot } from '@siafoundation/renterd-js'

export async function example() {
  const bus = Bus({
    api: 'http://localhost:9980/api',
    password: 'password1337',
  })
  const autopilot = Autopilot({
    api: 'http://localhost:9980/api',
    password: 'password1337',
  })
  const worker = Worker({
    api: 'http://worker:4444/api',
    password: 'password1337',
  })

  try {
    const buckets = await bus.buckets()
    buckets.data.forEach((bucket) => {
      console.log(bucket.name, bucket.createdAt, bucket.policy)
    })
  } catch (error) {
    console.log(error)
  }

  bus.bucketCreate({
    data: { name: 'my-bucket' },
  })

  bus.bucketPolicyUpdate({
    params: {
      name: 'my-bucket',
    },
    data: {
      policy: {
        publicReadAccess: true,
      },
    },
  })

  const hosts = await bus.hosts({
    data: {
      filterMode: 'allowed',
      usabilityMode: 'usable',
      addressContains: 'example.com',
      keyIn: ['key1', 'key2'],
      offset: 0,
      limit: 50,
    },
  })

  hosts.data?.forEach((host) => {
    console.log(host.publicKey, host.priceTable)
  })

  await worker.objectUpload({
    params: {
      key: 'path/to/file.txt',
      bucket: 'my-bucket',
    },
    data: new File(['file contents'], 'file.txt'),
    config: {
      onUploadProgress: (progress) => {
        console.log(progress.loaded / progress.total)
      },
    },
  })

  await worker.objectDownload({
    params: {
      key: 'path/to/file.txt',
      bucket: 'my-bucket',
    },
  })

  const state = await autopilot.state()
  console.log(state.data.migrating)
}
0.14.4-beta.0

2 months ago

0.14.4-beta.1

2 months ago

0.12.0

7 months ago

0.13.0

6 months ago

0.12.1

7 months ago

0.14.0

4 months ago

0.13.1

5 months ago

0.12.2

7 months ago

0.14.1

4 months ago

0.14.2

4 months ago

0.14.3

2 months ago

0.14.4

2 months ago

0.11.0

9 months ago

0.10.1

9 months ago

0.10.0

9 months ago

0.9.0

10 months ago

0.3.0

1 year ago

0.8.0

10 months ago

0.5.0

11 months ago

0.4.0

11 months ago

0.2.2

1 year ago

0.7.0

10 months ago

0.6.1

11 months ago

0.6.0

11 months ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago