Skip to content

golemfactory/yajsapi

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

* Fixed UploadFile command (#479)

* Fixed unit tests (#479)

* Increased timeouts for unit tests (windows failed) (#479)

* Increased activity default timeout (#479)

* Added integration test (#479)
3969026

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Golem JavaScript API

GitHub npm node-current npm type definitions GitHub Workflow Status GitHub issues Discord

What's Golem and yajsapi?

The Golem Network fosters a global group of creators building ambitious software solutions that will shape the technological landscape of future generations by accessing computing resources across the platform. Golem Network is an accessible, reliable, open access and censorship-resistant protocol, democratizing access to digital resources and connecting users through a flexible, open-source platform.

Yajsapi is the JavaScript API that allows developers to connect to their Golem nodes and manage their distributed, computational loads through Golem Network.

Golem application development

For a detailed introduction to using Golem and yajsapi to run your tasks on Golem please consult our quickstart section.

Installation

yajsapi is available as a NPM package.

You can install it through npm:

npm install yajsapi

or by yarn:

yarn add yajsapi

Building

To build a library available to the nodejs environment:

npm run build
# or
yarn build

This will generate production code in the dist/ directory ready to be used in your nodejs or browser applications.

Usage

Hello World

import { TaskExecutor } from "yajsapi";

(async function main() {
  const executor = await TaskExecutor.create("9a3b5d67b0b27746283cb5f287c13eab1beaa12d92a9f536b747c7ae");
  await executor.run(async (ctx) => console.log(await ctx.run("echo 'Hello World'")).stdout);
  await executor.end();
})();

Node.js context

hello_nodejs

Web Browser context

hello_web

For more detailed usage examples and tutorials, see the Java Script API section of the Golem Network Docs

Testing

Running unit tests

To run unit tests, you can simply execute the command:

npm run test:unit
# or
yarn test:unit

Running integration tests

Both test cases for the nodejs environment and the browser (cypress) require preparation of a test environment of the golem network with providers and all the necessary infrastructure. Goth framework is used for this purpose.

To enable integration testing, you need to ensure that python -m goth is executable. Therefore, you must first install Goth according to the instructions described in the readme of the project.

Nodejs

npm run test:integration
# or
yarn test:integration

Cypress

npm run test:cypress
# or
yarn test:cypress

Contributing

It is recommended to run unit tests and static code analysis before committing changes.

yarn lint
# and
yarn format

See also