Skip to content

feat: renterd-js library#582

Merged
alexfreska merged 1 commit intomainfrom
feat_renterd-js_library
Apr 16, 2024
Merged

feat: renterd-js library#582
alexfreska merged 1 commit intomainfrom
feat_renterd-js_library

Conversation

@alexfreska
Copy link
Member

@alexfreska alexfreska commented Apr 15, 2024

This PR adds a renterd-js library.

npm install @siafoundation/renterd-js
import { Bus } from './bus'
import { Autopilot } from './autopilot'
import { Worker } from './worker'

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

  const buckets = await bus.buckets()

  buckets.data.forEach((bucket) => {
    console.log(bucket.name, bucket.createdAt, bucket.policy)
  })

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

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

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

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

  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)
      },
    },
  })

  worker.objectDownload({
    params: {
      key: 'path/to/file.txt',
      bucket: 'my-bucket',
    },
    config: {
      onDownloadProgress: (progress) => {
        console.log(progress.loaded / progress.total)
      },
    },
  })
}

@changeset-bot
Copy link

changeset-bot bot commented Apr 15, 2024

🦋 Changeset detected

Latest commit: 17bcc75

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@siafoundation/renterd-js Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@alexfreska alexfreska force-pushed the refactor_renterd_libs_extract_route_variables branch from f9c86ce to 2cf79e3 Compare April 15, 2024 15:00
@alexfreska alexfreska force-pushed the feat_renterd-js_library branch from eee1429 to d9ecf44 Compare April 15, 2024 15:00
@alexfreska alexfreska force-pushed the refactor_renterd_libs_extract_route_variables branch from 2cf79e3 to f932321 Compare April 15, 2024 15:06
@alexfreska alexfreska force-pushed the feat_renterd-js_library branch from d9ecf44 to 8912aa8 Compare April 15, 2024 15:06
@alexfreska alexfreska force-pushed the refactor_renterd_libs_extract_route_variables branch from f932321 to d82ee4d Compare April 15, 2024 15:22
@alexfreska alexfreska force-pushed the feat_renterd-js_library branch from 8912aa8 to e4b65db Compare April 15, 2024 15:22
@alexfreska alexfreska force-pushed the refactor_renterd_libs_extract_route_variables branch from d82ee4d to 6fb785e Compare April 15, 2024 15:30
@alexfreska alexfreska force-pushed the feat_renterd-js_library branch from e4b65db to 6045dc8 Compare April 15, 2024 15:31
@alexfreska alexfreska force-pushed the refactor_renterd_libs_extract_route_variables branch from 6fb785e to c5edf5f Compare April 15, 2024 15:57
@alexfreska alexfreska force-pushed the feat_renterd-js_library branch from 6045dc8 to 5fb0c32 Compare April 15, 2024 15:57
@alexfreska alexfreska force-pushed the refactor_renterd_libs_extract_route_variables branch from c5edf5f to 443c8fb Compare April 15, 2024 16:14
@alexfreska alexfreska force-pushed the feat_renterd-js_library branch from 5fb0c32 to 6e37d29 Compare April 15, 2024 16:14
@alexfreska alexfreska force-pushed the refactor_renterd_libs_extract_route_variables branch from 443c8fb to 6e95d64 Compare April 15, 2024 16:38
@alexfreska alexfreska force-pushed the feat_renterd-js_library branch from 6e37d29 to f39d6e7 Compare April 15, 2024 16:38
@alexfreska alexfreska force-pushed the refactor_renterd_libs_extract_route_variables branch from 6e95d64 to 06a0c9c Compare April 15, 2024 18:35
@alexfreska alexfreska force-pushed the feat_renterd-js_library branch 3 times, most recently from ff0a699 to 8035633 Compare April 15, 2024 18:42
@alexfreska alexfreska force-pushed the refactor_renterd_libs_extract_route_variables branch from 06a0c9c to 3f50d41 Compare April 15, 2024 18:59
@alexfreska alexfreska force-pushed the feat_renterd-js_library branch from 8035633 to 2a240da Compare April 15, 2024 18:59
@alexfreska alexfreska force-pushed the refactor_renterd_libs_extract_route_variables branch from 3f50d41 to 9b69766 Compare April 15, 2024 19:51
@alexfreska alexfreska force-pushed the feat_renterd-js_library branch from 2a240da to fd1fdc3 Compare April 15, 2024 19:51
Copy link
Member

@n8mgr n8mgr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexfreska alexfreska force-pushed the refactor_renterd_libs_extract_route_variables branch from 9b69766 to 2f4023c Compare April 15, 2024 20:34
@alexfreska alexfreska force-pushed the feat_renterd-js_library branch from fd1fdc3 to b104b8f Compare April 15, 2024 20:34
@alexfreska alexfreska force-pushed the refactor_renterd_libs_extract_route_variables branch from 2f4023c to 833c8f9 Compare April 15, 2024 21:15
@alexfreska alexfreska force-pushed the feat_renterd-js_library branch from b104b8f to 5288041 Compare April 15, 2024 21:15
@alexfreska alexfreska requested a review from n8mgr April 15, 2024 21:51
Copy link
Member Author

alexfreska commented Apr 16, 2024

Merge activity

  • Apr 16, 8:33 AM EDT: @alexfreska started a stack merge that includes this pull request via Graphite.
  • Apr 16, 8:37 AM EDT: Graphite rebased this pull request as part of a merge.
  • Apr 16, 8:38 AM EDT: @alexfreska merged this pull request with Graphite.

@alexfreska alexfreska changed the base branch from refactor_renterd_libs_extract_route_variables to main April 16, 2024 12:34
@graphite-app
Copy link

graphite-app bot commented Apr 16, 2024

Graphite Automations

"Auto-assign PRs to author" took an action on this PR • (04/16/24)

1 assignee was added to this PR based on Alex Freska's automation.

@alexfreska alexfreska force-pushed the feat_renterd-js_library branch from 5288041 to 17bcc75 Compare April 16, 2024 12:36
@alexfreska alexfreska merged commit 7b1f466 into main Apr 16, 2024
@alexfreska alexfreska deleted the feat_renterd-js_library branch June 7, 2024 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants