mirror of
https://github.com/n8n-io/n8n-nodes-starter.git
synced 2025-10-29 06:22:24 -05:00
chore: ExampleNode2 added
This commit is contained in:
parent
ef0e46c328
commit
21f7bc4eae
3 changed files with 4666 additions and 0 deletions
77
nodes/ExampleNode2/ExampleNode2.node.ts
Normal file
77
nodes/ExampleNode2/ExampleNode2.node.ts
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
import type {
|
||||||
|
IExecuteFunctions,
|
||||||
|
INodeExecutionData,
|
||||||
|
INodeType,
|
||||||
|
INodeTypeDescription,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
import { NodeConnectionType, NodeOperationError } from 'n8n-workflow';
|
||||||
|
|
||||||
|
export class ExampleNode2 implements INodeType {
|
||||||
|
description: INodeTypeDescription = {
|
||||||
|
displayName: 'Example Node 2',
|
||||||
|
name: 'exampleNode2',
|
||||||
|
group: ['transform'],
|
||||||
|
version: 1,
|
||||||
|
description: 'Basic Example Node',
|
||||||
|
defaults: {
|
||||||
|
name: 'Example Node',
|
||||||
|
},
|
||||||
|
inputs: [NodeConnectionType.Main],
|
||||||
|
outputs: [NodeConnectionType.Main],
|
||||||
|
usableAsTool: true,
|
||||||
|
properties: [
|
||||||
|
// Node properties which the user gets displayed and
|
||||||
|
// can change on the node.
|
||||||
|
{
|
||||||
|
displayName: 'My String',
|
||||||
|
name: 'myString',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
placeholder: 'Placeholder value',
|
||||||
|
description: 'The description text',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
// The function below is responsible for actually doing whatever this node
|
||||||
|
// is supposed to do. In this case, we're just appending the `myString` property
|
||||||
|
// with whatever the user has entered.
|
||||||
|
// You can make async calls and use `await`.
|
||||||
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
|
const items = this.getInputData();
|
||||||
|
|
||||||
|
let item: INodeExecutionData;
|
||||||
|
let myString: string;
|
||||||
|
|
||||||
|
// Iterates over all input items and add the key "myString" with the
|
||||||
|
// value the parameter "myString" resolves to.
|
||||||
|
// (This could be a different value for each item in case it contains an expression)
|
||||||
|
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||||
|
try {
|
||||||
|
myString = this.getNodeParameter('myString', itemIndex, '') as string;
|
||||||
|
item = items[itemIndex];
|
||||||
|
|
||||||
|
item.json.myString = myString;
|
||||||
|
} catch (error) {
|
||||||
|
// This node should never fail but we want to showcase how
|
||||||
|
// to handle errors.
|
||||||
|
if (this.continueOnFail()) {
|
||||||
|
items.push({ json: this.getInputData(itemIndex)[0].json, error, pairedItem: itemIndex });
|
||||||
|
} else {
|
||||||
|
// Adding `itemIndex` allows other workflows to handle this error
|
||||||
|
if (error.context) {
|
||||||
|
// If the error thrown already contains the context property,
|
||||||
|
// only append the itemIndex
|
||||||
|
error.context.itemIndex = itemIndex;
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
throw new NodeOperationError(this.getNode(), error, {
|
||||||
|
itemIndex,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [items];
|
||||||
|
}
|
||||||
|
}
|
||||||
4588
package-lock.json
generated
Normal file
4588
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -38,6 +38,7 @@
|
||||||
],
|
],
|
||||||
"nodes": [
|
"nodes": [
|
||||||
"dist/nodes/ExampleNode/ExampleNode.node.js",
|
"dist/nodes/ExampleNode/ExampleNode.node.js",
|
||||||
|
"dist/nodes/ExampleNode2/ExampleNode2.node.js",
|
||||||
"dist/nodes/HttpBin/HttpBin.node.js"
|
"dist/nodes/HttpBin/HttpBin.node.js"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue