Skip to main content

Usage

The Node API is available in select Node operations. It is provided as a context object, and can be accessed through the api property. The Node API is used to interact with the node that is currently being operated on.

// Create a new Scribe instance
const scribe = new Scribe();

// Create a new node
const node = await scribe.createNode({
ops: {
init: async ({ api }, next) => {
api.register("nodeCreated", true);
await next();
},
},
run: async ({ api }, next) => {
console.log(`Node created: ${api.get("nodeCreated") ?? false}`);
await next();
},
});