PATTERNS TO MAKE YOUR OWN

Less theory.
More working code.

Real patterns from the library documentation. Copy them, adapt them,
and keep framework dependencies in your application.

SELECTED EXAMPLE

Double a number

Runnable JavaScript factory
workflow.tsTypeScript
import { Engine, Workflow } from "@newvexa/workify";

export function createWorkflowEngine() {
  const workflow = new Workflow({ id: "demo", name: "Double a number" });

  workflow.addNode({
    id: "start",
    name: "Receive input",
    type: "trigger",
    async execute(input) {
      return { outputs: { main: input.initial } };
    },
  });

  workflow.addNode({
    id: "double",
    name: "Double the value",
    type: "action",
    async execute(input, context) {
      context.signal.throwIfAborted();
      const value = input.incoming[0]?.value;
      if (typeof value !== "number") throw new Error("Expected a number");
      return { outputs: { main: value * 2 } };
    },
  });

  workflow.addLink({
    id: "start-double",
    name: "Input to calculation",
    source: { nodeId: "start", port: "main" },
    target: { nodeId: "double", port: "main" },
  });

  return new Engine(workflow, { concurrency: 4, historyLimit: 500 });
}

Create the factory, then explicitly run the returned engine with await engine.run(21). The expected double output is 42.

BEYOND THE CORE

Bring your own side effects.

The separately imported HTTP adapter example demonstrates timeouts, exponential backoff, jitter, Retry-After handling, cancellation, and idempotency checks. This is not automatic engine retry behavior. Its tests simulate HTTP; they do not call external services.

Explore the HTTP adapter