Skip to content

ethercards/galaxis-feed-bee-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Galaxis Feed Bee JS

This document provides an overview of the Galaxis Feed Bee JS application.

Table of Contents

  1. Introduction
  2. Installation
  3. Usage
  4. API

Introduction

Galaxis Feed Bee JS is a JavaScript library designed to interact with the Galaxis Feed Bee API. It provides a simple and efficient way to manage and retrieve feed data.

Installation

To install the library, use npm or yarn:

npm install git+https://github.com/ethercards/galaxis-feed-be-js.git

or

yarn add git+https://github.com/ethercards/galaxis-feed-be-js.git

Usage

Here is an example of how to use the library in your project. The main entry point is index.ts.

import { feed, buy } from "galaxis-feed-be-js";

async function execBuy() {
  process.env.BEE_URL = "http://localhost:1633/1/"; // Set your bee node URL
  // Calling buy, the process.env.BATCH_ID can be any string
  process.env.BATCH_ID = "no-id"; // For feed, upload, uploadFilesFromDirectory
  const response = await buy(file, "/all.json");
}

async function execFeed() {
  process.env.BEE_URL = "http://localhost:1633/1/"; // Set your bee node URL
  // Calling buy, the process.env.BATCH_ID can be any string
  process.env.BATCH_ID =
    "a0ba418731296d4ca653452f11cb45653764b8d9d18ca32bd4e2fd932c70c53d"; // For feed, upload, uploadFilesFromDirectory
  const response = await feed(file, "/all.json");
}

API

buy(amount: string, depth: string): Promise<CreatePostageBatchResponse>

Buy batchId

  • Parameters:

    • amount (string): Describe batch TTL.
    • depth (string): Describe storage space.
  • Returns:

feed(file: string, topic: string): Promise<string>

Purchases the specified item in the given quantity.

  • Parameters:

    • file (string): File to upload.
    • topic (string): The path on Swarm.
  • Returns:

    • Promise<string>: Reference URL for the uploaded file.

uploadFile(file: string): Promise<UploadResultWithCid>

Upload a given file to Swarm

uploadFilesFromDirectory(path: string): Promise<UploadResultWithCid>

Upload a given file to Swarm