mirror of
https://github.com/n8n-io/n8n-nodes-starter.git
synced 2025-10-28 14:12:24 -05:00
Merge pull request #17 from n8n-io/more-general-improvements
More general improvements
This commit is contained in:
commit
71f3e518d7
10 changed files with 66 additions and 145 deletions
|
|
@ -1,5 +1,10 @@
|
|||
import { IExecuteFunctions } from 'n8n-core';
|
||||
import { INodeExecutionData, INodeType, INodeTypeDescription, NodeOperationError } from 'n8n-workflow';
|
||||
import {
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export class ExampleNode implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
|
|
@ -10,7 +15,6 @@ export class ExampleNode implements INodeType {
|
|||
description: 'Basic Example Node',
|
||||
defaults: {
|
||||
name: 'Example Node',
|
||||
color: '#772244',
|
||||
},
|
||||
inputs: ['main'],
|
||||
outputs: ['main'],
|
||||
|
|
@ -48,11 +52,10 @@ export class ExampleNode implements INodeType {
|
|||
|
||||
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});
|
||||
items.push({ json: this.getInputData(itemIndex)[0].json, error });
|
||||
} else {
|
||||
// Adding `itemIndex` allows other workflows to handle this error
|
||||
if (error.context) {
|
||||
|
|
@ -66,7 +69,6 @@ export class ExampleNode implements INodeType {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return this.prepareOutputData(items);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
/* eslint-disable n8n-nodes-base/filesystem-wrong-node-filename */
|
||||
import { INodeType, INodeTypeDescription } from 'n8n-workflow';
|
||||
import { httpVerbFields, httpVerbOperations } from './HttpVerbDescriptions';
|
||||
import { httpVerbFields, httpVerbOperations } from './HttpVerbDescription';
|
||||
|
||||
export class HttpBin implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'HttpBin',
|
||||
name: 'httpbin',
|
||||
name: 'httpBin',
|
||||
icon: 'file:httpbin.svg',
|
||||
group: ['transform'],
|
||||
version: 1,
|
||||
|
|
@ -36,11 +35,10 @@ export class HttpBin implements INodeType {
|
|||
*
|
||||
* [Resource & Operation]
|
||||
*
|
||||
*
|
||||
* https://docs.n8n.io/integrations/creating-nodes/code/create-first-node/#resources-and-operations
|
||||
*
|
||||
* In our example, the operations are separated into their own file (HTTPVerbDescription)
|
||||
* to keep this class easy to read
|
||||
* In our example, the operations are separated into their own file (HTTPVerbDescription.ts)
|
||||
* to keep this class easy to read.
|
||||
*
|
||||
*/
|
||||
properties: [
|
||||
|
|
@ -52,10 +50,10 @@ export class HttpBin implements INodeType {
|
|||
options: [
|
||||
{
|
||||
name: 'HTTP Verb',
|
||||
value: 'httpverbs',
|
||||
value: 'httpVerb',
|
||||
},
|
||||
],
|
||||
default: 'httpverbs',
|
||||
default: 'httpVerb',
|
||||
},
|
||||
|
||||
...httpVerbOperations,
|
||||
|
|
|
|||
|
|
@ -1,21 +1,23 @@
|
|||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
// This maps the operations to when the Resource option HTTP Verbs is selected
|
||||
// When the resource `httpVerb` is selected, this `operation` parameter will be shown.
|
||||
export const httpVerbOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['httpverbs'],
|
||||
resource: ['httpVerb'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'GET',
|
||||
value: 'get',
|
||||
action: 'Perform a GET request',
|
||||
routing: {
|
||||
request: {
|
||||
method: 'GET',
|
||||
|
|
@ -26,6 +28,7 @@ export const httpVerbOperations: INodeProperties[] = [
|
|||
{
|
||||
name: 'DELETE',
|
||||
value: 'delete',
|
||||
action: 'Perform a DELETE request',
|
||||
routing: {
|
||||
request: {
|
||||
method: 'DELETE',
|
||||
|
|
@ -38,8 +41,8 @@ export const httpVerbOperations: INodeProperties[] = [
|
|||
},
|
||||
];
|
||||
|
||||
// Here we define what to show when the GET Operation is selected
|
||||
// We do that by adding operation: ["get"], to "displayOptions.show"
|
||||
// Here we define what to show when the `get` operation is selected.
|
||||
// We do that by adding `operation: ["get"]` to `displayOptions.show`
|
||||
const getOperation: INodeProperties[] = [
|
||||
{
|
||||
name: 'typeofData',
|
||||
|
|
@ -48,7 +51,7 @@ const getOperation: INodeProperties[] = [
|
|||
displayName: 'Type of Data',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['httpverbs'],
|
||||
resource: ['httpVerb'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
|
|
@ -68,7 +71,7 @@ const getOperation: INodeProperties[] = [
|
|||
displayName: 'Query Parameters',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['httpverbs'],
|
||||
resource: ['httpVerb'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
|
|
@ -109,8 +112,8 @@ const getOperation: INodeProperties[] = [
|
|||
},
|
||||
];
|
||||
|
||||
// Here we define what to show when the DELETE Operation is selected
|
||||
// We do that by adding operation: ["delete"], to "displayOptions.show"
|
||||
// Here we define what to show when the DELETE Operation is selected.
|
||||
// We do that by adding `operation: ["delete"]` to `displayOptions.show`
|
||||
const deleteOperation: INodeProperties[] = [
|
||||
{
|
||||
name: 'typeofData',
|
||||
|
|
@ -119,7 +122,7 @@ const deleteOperation: INodeProperties[] = [
|
|||
displayName: 'Type of Data',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['httpverbs'],
|
||||
resource: ['httpVerb'],
|
||||
operation: ['delete'],
|
||||
},
|
||||
},
|
||||
|
|
@ -143,7 +146,7 @@ const deleteOperation: INodeProperties[] = [
|
|||
displayName: 'Query Parameters',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['httpverbs'],
|
||||
resource: ['httpVerb'],
|
||||
operation: ['delete'],
|
||||
typeofData: ['queryParameter'],
|
||||
},
|
||||
|
|
@ -190,7 +193,7 @@ const deleteOperation: INodeProperties[] = [
|
|||
displayName: 'JSON Object',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['httpverbs'],
|
||||
resource: ['httpVerb'],
|
||||
operation: ['delete'],
|
||||
typeofData: ['jsonData'],
|
||||
},
|
||||
|
|
@ -234,12 +237,12 @@ const deleteOperation: INodeProperties[] = [
|
|||
|
||||
export const httpVerbFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Http Verbs:Get */
|
||||
/* httpVerb:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
...getOperation,
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* Http Verbs:Delete */
|
||||
/* httpVerb:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
...deleteOperation,
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue