This Coherent Spark Node.js SDK provides a convenient way to interact with the Hybrid Runner API.
This guide assumes that you are familiar with Coherent Spark's hybrid deployments. Otherwise, visit the User Guide to learn more about it.
npm install @cspark/wasm
# or
yarn add @cspark/wasm
@cspark/wasm
is an extension of @cspark/sdk
.
Obviously, a runner offers a smaller subset of functionality compared to the SaaS API,
however, extending @cspark/sdk
to support the Hybrid Runner API is a good way
to keep the codebase consistent and maintainable. This means, you will need to
install the @cspark/sdk
package as a peer dependency. That also means that you may
want to check its documentation to learn about its client options,
error handling, and other features.
To interact with the Hybrid Runner API, create a HybridClient
that points to the
runner's base URL (by default: http://localhost:3000
). Depending on your hybrid
runner's configuration, you may or may not need to use authentication.
import Hybrid from '@cspark/wasm';
function main() {
const hybrid = new Hybrid({ tenant: 'my-tenant', token: 'open' }); // no authentication
hybrid.services
.execute('my-folder/my-service', { inputs: { value: 42 } })
.then((response) => console.log(response.data))
.catch(console.error);
}
main();
Explore the examples and docs folders to find out more about its capabilities.
Visit CONTRIBUTING.md for details on the contribution guidelines, the code of conduct, and the process for submitting pull requests.