集成节点/Creating_nodes/Build_your_node/Reference/Base_files
节点基础文件结构#
节点基础文件遵循以下基本结构:
- 添加导入语句
- 创建节点类
- 在节点类中创建
description对象,用于定义节点
编程式节点还包含一个 execute() 方法,该方法负责读取输入数据和参数,然后构建请求。而声明式节点则通过在 description 内的 properties 对象中使用 routing 键来处理此过程。
声明式节点结构概览#
以下代码片段展示了节点的结构概览:
1
2
3
4
5
6
7
8
9
10| ``` import{INodeType,INodeTypeDescription}from'n8n-workflow';
exportclassExampleNodeimplementsINodeType{ description:INodeTypeDescription={ // 基础节点信息在此定义 properties:[ // 资源和操作在此定义 ] }; }
---|---
有关所有节点类型可用参数的信息,请参阅[标准参数](https://docs.n8n.io/integrations/creating-nodes/build/reference/node-base-files/standard-parameters/)。有关声明式节点可用参数的信息,请参阅[声明式参数](https://docs.n8n.io/integrations/creating-nodes/build/reference/node-base-files/declarative-style-parameters/)。
## 编程式节点结构概览[#](https://docs.n8n.io/integrations/creating-nodes/build/reference/node-base-files/structure/#outline-structure-for-a-programmatic-style-node "永久链接")
以下代码片段展示了节点的结构概览:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| ```
import{IExecuteFunctions}from'n8n-core';
import{INodeExecutionData,INodeType,INodeTypeDescription}from'n8n-workflow';
exportclassExampleNodeimplementsINodeType{
description:INodeTypeDescription={
// 基础节点信息在此定义
properties:[
// 资源和操作在此定义
]
};
asyncexecute(this:IExecuteFunctions):Promise<INodeExecutionData[][]>{
// 处理数据并返回结果
}
};
---|---
有关所有节点类型可用参数的信息,请参阅[标准参数](https://docs.n8n.io/integrations/creating-nodes/build/reference/node-base-files/standard-parameters/)。如需了解编程式节点的使用方法,请参考[编程式参数](https://docs.n8n.io/integrations/creating-nodes/build/reference/node-base-files/programmatic-style-parameters/)和[编程式执行方法](https://docs.n8n.io/integrations/creating-nodes/build/reference/node-base-files/programmatic-style-execute-method/)。