Node
Nodes are the core building blocks of your nanoservice-ts applications, encapsulating specific pieces of logic. The nanoctl
CLI provides commands to help you create and manage these Nodes efficiently, primarily through the create node
command.
create node
This command is used to scaffold a new Node within your nanoservice-ts project.
Purpose: To generate the boilerplate files for a new Node, including its definition (node.json
) and implementation file (e.g.,index.ts
), placing them in the appropriate directory within your project (usuallynodes/
).
Usage:
1. Interactive Prompts & Options
You will be prompted to provide the following information:
-
Node Name
Enter a unique name for the node (e.g.,fetch
). -
Select Runtime
Choose between:- TypeScript (recommended) (Default)
- Python3 (Alpha version, MacOS & Linux only)
(For this guide, select TypeScript.)
-
Select Nanoservice Type
Choose between:- Module (For npm-published nodes – not needed for this guide)
- Class (Default, for local nodes)
-
Select Template
Choose between:- Class (recommended) (Default)
- UI - EJS - REACTJS - TailwindCSS (not required for this guide)
2. Navigate to the New Node Directory:
Once the node is created, navigate to its directory:
3. Update the Node Class Name
Open the index.ts
file inside the node directory and update the class name to match your node name (Fetch
in this example):
4. Register the Node in the Nodes.ts
File
To make your node available in workflows, register it inside src/Nodes.ts
:
5. Validate the Node
To verify that your new node has been registered correctly, run the following command from the root of your project:
If everything works as expected, the node is ready to be used in a workflow. Simply create a workflow and add your node to it.
Summary
- ✅ Created a custom node using the CLI.
- ✅ Configured the node class name correctly.
- ✅ Registered the node inside
Nodes.ts
. - ✅ Validated the project setup.
Your node is now ready to be used in workflows! 🎉