Blok
, defining the orchestration of Nodes to implement business logic. The nanoctl
CLI helps in scaffolding new workflow definition files, primarily through the create workflow
command.
create workflow
Purpose: To create a boilerplate JSON file for a new workflow, placing it in the workflows/
directory of your project. This file will contain a basic structure that you can then customize to define your specific sequence of nodes and trigger configuration.
Usage:
To create a new workflow, run the following command:
nanoctl create workflow
, you might be prompted for:
workflows/json/cats.json
:
trigger
defines how the workflow is executed:
method
: Specifies the HTTP method (e.g., GET
, POST
, etc.). Use "*"
to accept any method.path
: Defines the URL path. Supports path parameters:
"/:id"
→ Required parameter (e.g., /cats/123
)."/:id?"
→ Optional parameter (e.g., /cats
or /cats/123
).accept
: Defines the expected response format (application/json
by default).steps
define the sequence of nodes executed in the workflow:
name
: Unique name for the step.node
: The node to execute (e.g., @nanoservice-ts/api-call
).type
: Specifies the type of node. The available options are:
module
: Used for nodes installed as dependencies (e.g., from npm) or nodes created using the Class
type.local
: Used for nodes created locally, typically intended for publishing to npm.nodes
section configures each node used in the workflow:
inputs
: Configuration values for the node.
url
: API endpoint.method
: HTTP method (GET
, POST
, etc.).headers
: Optional request headers.curl
or Postman:
/cats
path corresponds to the workflow JSON file workflows/json/cats.json
.
GET
, POST
, etc.) and dynamic paths (/:id
).curl
or Postman.