![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@ethersphere/bee-js
Advanced tools
Client library for connecting to Bee decentralised storage
Warning: This project is in beta state. There might (and most probably will) be changes in the future to its API and working. Also, no guarantees can be made about its stability, efficiency, and security at this stage.
> npm install @ethersphere/bee-js --save
We require Node.js's version of at least 12.x
var BeeJs = require("@ethersphere/bee-js");
var BeeJs = require("@ethersphere/bee-js");
Loading this module through a script tag will make the BeeJs
object available in the global namespace.
<script src="https://unpkg.com/@ethersphere/bee-js/dist/index.browser.min.js"></script>
import { Bee } from "@ethersphere/bee-js"
bee = new Bee("http://localhost:1633")
const fileHash = await bee.uploadData("Bee is awesome!")
const data = await bee.downloadData(fileHash)
console.log(data.text()) // prints 'Bee is awesome!'
You can find the full documentation here. The API reference documentation can be found here.
You can generate API docs locally with:
npm run docs
The generated docs can be viewed in browser by opening ./docs/index.html
There are some ways you can make this module better:
Install project dependencies with
npm i
The tests run in both context: node and dom with Jest.
To run the integration tests, you need to have a Bee cluster running locally. To create a cluster, please consult the readme of @ethersphere/bee-local.
By default, tests are run against local bee node 0 - http://bee-0.localhost
. You can change it by setting environment variable BEE_API_URL
.
In order to run tests which require one more node, you need to define BEE_PEER_API_URL
as well. Its default value http://bee-1.localhost
In Visual Studio environment, the tests have been set up to run against your local bee node on http://localhost:1633
To run Jest tests, choose the vscode-jest-tests
CI job under the Run tab.
You can run your own local Bee client for test purposes with the help of test/bee.sh.
If you pass --ephemeral
flag, the container automatically will be removed at the end of the run.
There are also browser tests by Puppeteer, which also provide integrity testing.
npm run test:browser
The test HTML file which Puppeteer uses is the test/testpage/testpage.html.
To open and manually test BeeJS with developer console, it is necessary to build the library first with npm run compile:browser
(running the browser tests npm run test:browser
also builds the library).
In order to compile NodeJS code run
npm run compile:node
or for Browsers
npm run compile:browser
0.8.0 (2021-04-19)
We understand that the current Feed's API is rather a low level and to use it for simple tasks might be overwhelming. We designed high-level API, that works for JSON data (arrays, objects, etc.) in a very convenient way. See the example bellow:
await bee.setJsonFeed(
'some cool arbitraty topic',
{ some: ['cool', { json: 'compatible' }, 'object']},
{ signer: '0x634fb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd' }
)
const data = await bee.getJsonFeed(
'some cool arbitraty topic',
{ signer: '0x634fb5a872396d9693e5c9f9d7233cfa93f395c093371017ff44aa9ae6564cdd' }
)
console.log(data)
// Prints: { some: ['cool', { json: 'compatible' }, 'object']}
BigInt
breaking changeJavaScript has limitations on how it can safely represent big numbers before floating errors come into the picture. Since the BZZ token has 16 decimal places we are able to safely represent only 0.9
BZZ which is not much. Because of this, we had to switch from using number
to bigint
type on money-related APIs that concerns balances, chequebook, and settlements.
As part of our internal code improvements, we have renamed all verify*
functions into assert*
. This mainly impacts BeeJS.Utils.Bytes
namespace where for example verifyBytes
was renamed to assertBytes
. As part of this change also the order of parameters was changed and some return types as well. If you use TypeScript the changes should be caught by our typings, if you are using JavaScript please verify you are not using these functions or refactor your code appropriately.
FAQs
Javascript client for Bee
The npm package @ethersphere/bee-js receives a total of 358 weekly downloads. As such, @ethersphere/bee-js popularity was classified as not popular.
We found that @ethersphere/bee-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.