const { submit } = require('@daggle/bacalhau-js')
const { Payload } = require("@daggle/bacalhau-js/models");
let data = new Payload({
ClientID: ...,
spec: ...
})
submit(data)
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
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()
Follow the below steps to run it locally.
- Clone Repo.
Change Host Initialize the SDK by passing in the host URL as parameter. ./src/sdk/config.js
$ git clone https://github.com/dagglexyz/bacalhau-js bacalhau-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()) { ...
- Create a simple node project
$ mkdir example-project $ cd example-project $ npm init
- Install package
$ npm install ../bacalhau-js
- 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()
This is not a production ready SDK, this repo will be moved to Bacalhau organization's GitHub and maintained by Bacalhau in the future.