🚚 Directorize and alphabetize nodes (#2445)

* 🚚 Directorize nodes

*  Alphabetize nodes and credentials

* 🔥 Remove unused node

* 🔥 Remove unused codex

* 🔥 Remove duplicate cred file references

* 🐛 Fix node file paths

* 🔥 Remove duplicate node reference
This commit is contained in:
Iván Ovejero
2021-11-17 17:30:14 +01:00
committed by GitHub
parent 0022c7eb09
commit 766f74c782
95 changed files with 109 additions and 472 deletions

View File

@@ -0,0 +1,28 @@
{
"node": "n8n-nodes-base.sseTrigger",
"nodeVersion": "1.0",
"codexVersion": "1.0",
"categories": [
"Development",
"Core Nodes"
],
"resources": {
"primaryDocumentation": [
{
"url": "https://docs.n8n.io/nodes/n8n-nodes-base.sseTrigger/"
}
],
"generic": [
{
"label": "What are APIs and how to use them with no code",
"icon": " 🪢",
"url": "https://n8n.io/blog/what-are-apis-how-to-use-them-with-no-code/"
}
]
},
"subcategories": {
"Core Nodes": [
"Flow"
]
}
}

View File

@@ -0,0 +1,57 @@
import * as EventSource from 'eventsource';
import { ITriggerFunctions } from 'n8n-core';
import {
INodeType,
INodeTypeDescription,
ITriggerResponse,
} from 'n8n-workflow';
export class SseTrigger implements INodeType {
description: INodeTypeDescription = {
displayName: 'SSE Trigger',
name: 'sseTrigger',
icon: 'fa:cloud-download-alt',
group: ['trigger'],
version: 1,
description: 'Triggers the workflow when Server-Sent Events occur',
defaults: {
name: 'SSE Trigger',
color: '#225577',
},
inputs: [],
outputs: ['main'],
properties: [
{
displayName: 'URL',
name: 'url',
type: 'string',
default: '',
placeholder: 'http://example.com',
description: 'The URL to receive the SSE from.',
required: true,
},
],
};
async trigger(this: ITriggerFunctions): Promise<ITriggerResponse> {
const url = this.getNodeParameter('url') as string;
const eventSource = new EventSource(url);
eventSource.onmessage = (event) => {
const eventData = JSON.parse(event.data);
this.emit([this.helpers.returnJsonArray([eventData])]);
};
async function closeFunction() {
eventSource.close();
}
return {
closeFunction,
};
}
}