From 380b617a5f1505a6a74b0723f51a16f27795d253 Mon Sep 17 00:00:00 2001 From: brianinoa Date: Tue, 14 Jun 2022 16:31:05 +0200 Subject: [PATCH] :zap: Create New HttpBin Declarative Node --- nodes/HttpBin/HttpBin.credentials.ts | 39 ++++++++++++++++++++++++++++ nodes/HttpBin/HttpBin.node.json | 21 +++++++++++++++ nodes/HttpBin/HttpBin.node.ts | 34 ++++++++++++++++++++++++ nodes/HttpBin/httpbin.svg | 18 +++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 nodes/HttpBin/HttpBin.credentials.ts create mode 100644 nodes/HttpBin/HttpBin.node.json create mode 100644 nodes/HttpBin/HttpBin.node.ts create mode 100644 nodes/HttpBin/httpbin.svg diff --git a/nodes/HttpBin/HttpBin.credentials.ts b/nodes/HttpBin/HttpBin.credentials.ts new file mode 100644 index 0000000..b6bbab1 --- /dev/null +++ b/nodes/HttpBin/HttpBin.credentials.ts @@ -0,0 +1,39 @@ +import { + IAuthenticateHeaderAuth, + ICredentialTestRequest, + ICredentialType, + INodeProperties, +} from "n8n-workflow"; + +export class HttpBinApi implements ICredentialType { + name = "HttpBinApi"; + displayName = "HttpBin API"; + documentationUrl = "httpbin"; + properties: INodeProperties[] = [ + { + displayName: "API Key", + name: "apiKey", + type: "string", + default: "", + }, + { + displayName: "Domain", + name: "domain", + type: "string", + default: "https://httpbin.org", + }, + ]; + authenticate = { + type: "headerAuth", + properties: { + name: "api-key", + value: "={{$credentials.apiKey}}", + }, + } as IAuthenticateHeaderAuth; + test: ICredentialTestRequest = { + request: { + baseURL: "={{$credentials?.domain}}/v3", + url: "/account", + }, + }; +} diff --git a/nodes/HttpBin/HttpBin.node.json b/nodes/HttpBin/HttpBin.node.json new file mode 100644 index 0000000..5f3ed05 --- /dev/null +++ b/nodes/HttpBin/HttpBin.node.json @@ -0,0 +1,21 @@ +{ + "node": "n8n-nodes-base.httpbin", + "nodeVersion": "1.0", + "codexVersion": "1.0", + "categories": [ + "HTTP Request & Response Service", + "Developer Tools" + ], + "resources": { + "credentialDocumentation": [ + { + "url": "https://docs.n8n.io/credentials/httpbin" + } + ], + "primaryDocumentation": [ + { + "url": "https://docs.n8n.io/nodes/n8n-nodes-base.httpbin/" + } + ] + } +} diff --git a/nodes/HttpBin/HttpBin.node.ts b/nodes/HttpBin/HttpBin.node.ts new file mode 100644 index 0000000..161c44b --- /dev/null +++ b/nodes/HttpBin/HttpBin.node.ts @@ -0,0 +1,34 @@ +import { INodeType, INodeTypeDescription } from "n8n-workflow"; + +export class HttpBin implements INodeType { + description: INodeTypeDescription = { + displayName: "HttpBin", + name: "httpbin", + icon: "file:httpbin.svg", + group: ["transform"], + version: 1, + subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', + description: "Interact with HttpBin API", + defaults: { + name: "Sendinblue", + color: "#044a75", + }, + inputs: ["main"], + outputs: ["main"], + credentials: [ + { + name: "sendinblueApi", + required: true, + }, + ], + requestDefaults: { + baseURL: "={{$credentials.domain}}", + url: "", + headers: { + Accept: "application/json", + "Content-Type": "application/json", + }, + }, + properties: [], + }; +} diff --git a/nodes/HttpBin/httpbin.svg b/nodes/HttpBin/httpbin.svg new file mode 100644 index 0000000..aee1de1 --- /dev/null +++ b/nodes/HttpBin/httpbin.svg @@ -0,0 +1,18 @@ + + + +