Coder Social home page Coder Social logo

nodejs-sdk's Introduction

Bacalhau JS🟨

const { submit } = require('@daggle/bacalhau-js')
const { Payload } =  require("@daggle/bacalhau-js/models");

let data = new Payload({
	ClientID: ...,
	spec: ...
})

submit(data)

Check examples↗️

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 0.10 or higher is required.

If this is a brand new project, make sure to create a package.json first with the npm init command.

Installation is done using the npm install command:

$ npm install @daggle/bacalhau-js

Example

const { submit } =  require("@daggle/bacalhau-js");

const {
Payload,
Spec,
PublisherSpec,
StorageSpec,
Deal,
JobSpecDocker,
} =  require("@daggle/bacalhau-js/models");

async function submitJob() {
	let data = new Payload({
	ClientID: getClientId(),
	spec: new Spec({
	deal: new Deal(),
	docker: new JobSpecDocker({
			image: "ubuntu",
			entrypoint: ["echo", "Hello World!"],
		}),
		engine: "Docker",
		publisher_spec: new PublisherSpec({ type:  "Estuary" }),
		timeout: 1800,
		verifier: "Noop",
		outputs: [
			new  StorageSpec({
				path: "/outputs",
				storage_source: "IPFS",
				name: "outputs",
			}),
		],
		}),
	});

	const  response = await submit(data);
	console.log(response);
}
submitJob()

Check complete example↗️

Local Testing

Follow the below steps to run it locally.

Clone repo⚙️

  1. Clone Repo.
    $ git clone https://github.com/dagglexyz/bacalhau-js bacalhau-js
    Change Host Initialize the SDK by passing in the host URL as parameter. ./src/sdk/config.js
    ...
    } = require("./config");
    // Change host here
    const  config = initializeSDK("http://127.0.0.1:1234");
    const  jobApi = new  JobApi(config);
    
    async  function  submit(data  =  new  Payload()) {
    ...
  2. Create a simple node project
    $ mkdir example-project
    $ cd example-project
    $ npm init
  3. Install package
    $ npm install ../bacalhau-js
  4. Testing, create a file at root, index.js.
    const { list} =  require("@daggle/bacalhau-js");
    
    async function listJobs() {
    	const response = await list();
    	console.log(response.jobs);
    }
    listJobs()

Note⚠️

This is not a production ready SDK, this repo will be moved to Bacalhau organization's GitHub and maintained by Bacalhau in the future.

nodejs-sdk's People

Contributors

xandramcc avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.