From 024e71cdf5813f681330279397951d450279911e Mon Sep 17 00:00:00 2001 From: Hiroyasu Nishiyama Date: Wed, 3 Feb 2021 16:34:17 +0900 Subject: [PATCH 1/4] add examples for HTTP in/response node --- .../http/01 - Create HTTP endpoint.json | 226 ++++++++++++++++++ .../http/02 - Handle query parameters.json | 135 +++++++++++ .../http/03 - Handle URL parameters.json | 135 +++++++++++ .../04 - Access HTTP request headers.json | 140 +++++++++++ .../http/05 - Post data to a flow.json | 135 +++++++++++ .../http/06 - Post file to a flow.json | 126 ++++++++++ .../http/07 - Working with cookies.json | 187 +++++++++++++++ 7 files changed, 1084 insertions(+) create mode 100644 packages/node_modules/@node-red/nodes/examples/network/http/01 - Create HTTP endpoint.json create mode 100644 packages/node_modules/@node-red/nodes/examples/network/http/02 - Handle query parameters.json create mode 100644 packages/node_modules/@node-red/nodes/examples/network/http/03 - Handle URL parameters.json create mode 100644 packages/node_modules/@node-red/nodes/examples/network/http/04 - Access HTTP request headers.json create mode 100644 packages/node_modules/@node-red/nodes/examples/network/http/05 - Post data to a flow.json create mode 100644 packages/node_modules/@node-red/nodes/examples/network/http/06 - Post file to a flow.json create mode 100644 packages/node_modules/@node-red/nodes/examples/network/http/07 - Working with cookies.json diff --git a/packages/node_modules/@node-red/nodes/examples/network/http/01 - Create HTTP endpoint.json b/packages/node_modules/@node-red/nodes/examples/network/http/01 - Create HTTP endpoint.json new file mode 100644 index 000000000..1ff7eb228 --- /dev/null +++ b/packages/node_modules/@node-red/nodes/examples/network/http/01 - Create HTTP endpoint.json @@ -0,0 +1,226 @@ +[ + { + "id": "87bd706a.aec93", + "type": "comment", + "z": "d41b4dd3.ecd6a", + "name": "Create an HTTP Endpoint", + "info": "The `HTTP In` and `HTTP Response` pair of nodes are the starting point for all HTTP endpoints you create.\n\nAny flow that starts with an `HTTP In` node must have a path to an `HTTP Response` node otherwise requests will eventually timeout.\n\nThe `HTTP Response` node uses the `payload` property of messages it receives as the body of the response. Other properties can be used to further customize the response - they are covered in other recipes.\n\nThe `Template` node provides a convenient way to embed a body of content into a flow. It may be desirable to maintain such static content outside of the flow.\n\nSee Node-RED cookbook [item](https://cookbook.nodered.org/http/create-an-http-endpoint) for details.", + "x": 230, + "y": 100, + "wires": [] + }, + { + "id": "7f10afe.b1faa5", + "type": "http in", + "z": "d41b4dd3.ecd6a", + "name": "", + "url": "/hello", + "method": "get", + "upload": false, + "swaggerDoc": "", + "x": 240, + "y": 140, + "wires": [ + [ + "db134063.83b7a" + ] + ] + }, + { + "id": "d5ce67fc.e6e608", + "type": "http response", + "z": "d41b4dd3.ecd6a", + "name": "", + "statusCode": "", + "headers": {}, + "x": 490, + "y": 140, + "wires": [] + }, + { + "id": "5a89ce70.db6d5", + "type": "http request", + "z": "d41b4dd3.ecd6a", + "name": "", + "method": "GET", + "ret": "txt", + "paytoqs": "ignore", + "url": "http://localhost:1880/hello", + "tls": "", + "persist": false, + "proxy": "", + "authType": "", + "x": 390, + "y": 280, + "wires": [ + [ + "18b48ed8.1072e1" + ] + ] + }, + { + "id": "31f7aabb.3fbe06", + "type": "inject", + "z": "d41b4dd3.ecd6a", + "name": "", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "", + "payloadType": "date", + "x": 240, + "y": 280, + "wires": [ + [ + "5a89ce70.db6d5" + ] + ] + }, + { + "id": "18b48ed8.1072e1", + "type": "debug", + "z": "d41b4dd3.ecd6a", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 550, + "y": 280, + "wires": [] + }, + { + "id": "3c61c12c.5abaae", + "type": "comment", + "z": "d41b4dd3.ecd6a", + "name": "Send HTTP request: http://localhost:1880/hello", + "info": "`http request` node can be used to make an **HTTP GET** request.\n\nSee Node-RED cookbook [item](https://cookbook.nodered.org/http/simple-get-request) for details.", + "x": 300, + "y": 200, + "wires": [] + }, + { + "id": "db134063.83b7a", + "type": "template", + "z": "d41b4dd3.ecd6a", + "name": "page", + "field": "payload", + "fieldType": "msg", + "format": "html", + "syntax": "mustache", + "template": "\n \n \n

Hello World!

\n \n", + "output": "str", + "x": 370, + "y": 140, + "wires": [ + [ + "d5ce67fc.e6e608" + ] + ] + }, + { + "id": "83e766b1.154438", + "type": "http request", + "z": "d41b4dd3.ecd6a", + "name": "", + "method": "GET", + "ret": "txt", + "paytoqs": "ignore", + "url": "", + "tls": "", + "persist": false, + "proxy": "", + "authType": "", + "x": 390, + "y": 360, + "wires": [ + [ + "188bc18.5487a3f" + ] + ] + }, + { + "id": "89c4d7a7.f8d798", + "type": "inject", + "z": "d41b4dd3.ecd6a", + "name": "", + "props": [ + { + "p": "payload" + }, + { + "p": "url", + "v": "http://localhost:1880/hello", + "vt": "str" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "", + "payloadType": "date", + "x": 240, + "y": 360, + "wires": [ + [ + "83e766b1.154438" + ] + ] + }, + { + "id": "188bc18.5487a3f", + "type": "debug", + "z": "d41b4dd3.ecd6a", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 550, + "y": 360, + "wires": [] + }, + { + "id": "a65364a3.c72a58", + "type": "comment", + "z": "d41b4dd3.ecd6a", + "name": "Set URL in HTTP request node setting panel", + "info": "`http request` node can be used to make an **HTTP GET** request.\n\nSee Node-RED cookbook [item](https://cookbook.nodered.org/http/simple-get-request) for details.", + "x": 490, + "y": 240, + "wires": [] + }, + { + "id": "47396a8e.6804f4", + "type": "comment", + "z": "d41b4dd3.ecd6a", + "name": "Set URL via url property of input message of HTTP request node", + "info": "Target URL of `http request` node can be specified via `url` property of input message.\n\nSee Node-RED cookbook [item](https://cookbook.nodered.org/http/set-request-url) for details.", + "x": 550, + "y": 320, + "wires": [] + } +] \ No newline at end of file diff --git a/packages/node_modules/@node-red/nodes/examples/network/http/02 - Handle query parameters.json b/packages/node_modules/@node-red/nodes/examples/network/http/02 - Handle query parameters.json new file mode 100644 index 000000000..1cf8f614f --- /dev/null +++ b/packages/node_modules/@node-red/nodes/examples/network/http/02 - Handle query parameters.json @@ -0,0 +1,135 @@ +[ + { + "id": "ac0b58f6.c85138", + "type": "http in", + "z": "d41b4dd3.ecd6a", + "name": "", + "url": "/hello-query", + "method": "get", + "upload": false, + "swaggerDoc": "", + "x": 260, + "y": 560, + "wires": [ + [ + "d9c345c7.c2e148" + ] + ] + }, + { + "id": "c110b7f7.22f238", + "type": "http response", + "z": "d41b4dd3.ecd6a", + "name": "", + "statusCode": "", + "headers": {}, + "x": 530, + "y": 560, + "wires": [] + }, + { + "id": "976b2bb3.f5ff98", + "type": "comment", + "z": "d41b4dd3.ecd6a", + "name": "Handle query parameters passed to an HTTP endpoint", + "info": "The `HTTP in` node can accept query parameters passwd to an HTTP endpoint. It use the `msg.req.query` property of the message sent by the HTTP In node to access the parameters.\n\nSee Node-RED cookbook [item](https://cookbook.nodered.org/http/handle-query-parameters) for details.", + "x": 320, + "y": 520, + "wires": [] + }, + { + "id": "77a6b44f.4695ac", + "type": "inject", + "z": "d41b4dd3.ecd6a", + "name": "", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "", + "payloadType": "date", + "x": 240, + "y": 660, + "wires": [ + [ + "9094aba0.095678" + ] + ] + }, + { + "id": "f523b8e.b5c8c48", + "type": "debug", + "z": "d41b4dd3.ecd6a", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 550, + "y": 660, + "wires": [] + }, + { + "id": "9a63c9c5.949128", + "type": "comment", + "z": "d41b4dd3.ecd6a", + "name": "Send HTTP GET request: http://localhost:1880/hello-query?name=Nick", + "info": "`http request` node can be used to send **HTTP GET** request.", + "x": 370, + "y": 620, + "wires": [] + }, + { + "id": "d9c345c7.c2e148", + "type": "template", + "z": "d41b4dd3.ecd6a", + "name": "page", + "field": "payload", + "fieldType": "msg", + "format": "html", + "syntax": "mustache", + "template": "\n \n \n

Hello {{req.query.name}}!

\n \n", + "output": "str", + "x": 410, + "y": 560, + "wires": [ + [ + "c110b7f7.22f238" + ] + ] + }, + { + "id": "9094aba0.095678", + "type": "http request", + "z": "d41b4dd3.ecd6a", + "name": "", + "method": "GET", + "ret": "txt", + "paytoqs": "ignore", + "url": "http://localhost:1880/hello-query?name=Nick", + "tls": "", + "persist": false, + "proxy": "", + "authType": "", + "x": 390, + "y": 660, + "wires": [ + [ + "f523b8e.b5c8c48" + ] + ] + } +] \ No newline at end of file diff --git a/packages/node_modules/@node-red/nodes/examples/network/http/03 - Handle URL parameters.json b/packages/node_modules/@node-red/nodes/examples/network/http/03 - Handle URL parameters.json new file mode 100644 index 000000000..0a60fa95d --- /dev/null +++ b/packages/node_modules/@node-red/nodes/examples/network/http/03 - Handle URL parameters.json @@ -0,0 +1,135 @@ +[ + { + "id": "9b2d7459.8dd598", + "type": "http in", + "z": "d41b4dd3.ecd6a", + "name": "", + "url": "/hello-param/:name", + "method": "get", + "upload": false, + "swaggerDoc": "", + "x": 290, + "y": 900, + "wires": [ + [ + "83753c80.5e271" + ] + ] + }, + { + "id": "7fe50f46.46209", + "type": "http response", + "z": "d41b4dd3.ecd6a", + "name": "", + "statusCode": "", + "headers": {}, + "x": 590, + "y": 900, + "wires": [] + }, + { + "id": "6e88d2b.828a92c", + "type": "comment", + "z": "d41b4dd3.ecd6a", + "name": "Handle URL parameters in an HTTP endpoint", + "info": "Named path parameters (e.g. `:name`) in the URL property can be used to identify parts of the path that can vary between requests.\n\nThe `msg.req.params` property is an object of key/value pairs for each path parameter.", + "x": 290, + "y": 860, + "wires": [] + }, + { + "id": "214bc398.b3482c", + "type": "http request", + "z": "d41b4dd3.ecd6a", + "name": "", + "method": "GET", + "ret": "txt", + "paytoqs": "ignore", + "url": "http://localhost:1880/hello-param/Nick", + "tls": "", + "persist": false, + "proxy": "", + "authType": "", + "x": 390, + "y": 1000, + "wires": [ + [ + "70c0eba4.5f0dc4" + ] + ] + }, + { + "id": "70c0eba4.5f0dc4", + "type": "debug", + "z": "d41b4dd3.ecd6a", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 550, + "y": 1000, + "wires": [] + }, + { + "id": "83753c80.5e271", + "type": "template", + "z": "d41b4dd3.ecd6a", + "name": "page", + "field": "payload", + "fieldType": "msg", + "format": "html", + "syntax": "mustache", + "template": "\n \n \n

Hello {{req.params.name}}!

\n \n", + "output": "str", + "x": 470, + "y": 900, + "wires": [ + [ + "7fe50f46.46209" + ] + ] + }, + { + "id": "89523bfe.6e5c18", + "type": "inject", + "z": "d41b4dd3.ecd6a", + "name": "", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "", + "payloadType": "date", + "x": 240, + "y": 1000, + "wires": [ + [ + "214bc398.b3482c" + ] + ] + }, + { + "id": "6276a6cd.5c3b18", + "type": "comment", + "z": "d41b4dd3.ecd6a", + "name": "Send HTTP GET request: http://localhost:1880/hello-param/Nick", + "info": "`http request` node can be used to send **HTTP GET** request.", + "x": 350, + "y": 960, + "wires": [] + } +] \ No newline at end of file diff --git a/packages/node_modules/@node-red/nodes/examples/network/http/04 - Access HTTP request headers.json b/packages/node_modules/@node-red/nodes/examples/network/http/04 - Access HTTP request headers.json new file mode 100644 index 000000000..ca41ede1c --- /dev/null +++ b/packages/node_modules/@node-red/nodes/examples/network/http/04 - Access HTTP request headers.json @@ -0,0 +1,140 @@ +[ + { + "id": "1ccc20e.71730df", + "type": "http in", + "z": "d41b4dd3.ecd6a", + "name": "", + "url": "/hello-headers", + "method": "get", + "upload": false, + "swaggerDoc": "", + "x": 270, + "y": 1260, + "wires": [ + [ + "3a62f641.2c0e8a" + ] + ] + }, + { + "id": "bc626348.1496d", + "type": "http response", + "z": "d41b4dd3.ecd6a", + "name": "", + "statusCode": "", + "headers": {}, + "x": 550, + "y": 1260, + "wires": [] + }, + { + "id": "b13b7c19.79cbd", + "type": "comment", + "z": "d41b4dd3.ecd6a", + "name": "Access HTTP request headers", + "info": " `msg.req.headers` property of the message sent by the `HTTP In` node to access the headers.\n\nSee Node-RED cookbook [item](https://cookbook.nodered.org/http/access-http-request-headers) for details.", + "x": 240, + "y": 1220, + "wires": [] + }, + { + "id": "7fe0fee5.f3ed7", + "type": "http request", + "z": "d41b4dd3.ecd6a", + "name": "", + "method": "GET", + "ret": "txt", + "paytoqs": "ignore", + "url": "http://localhost:1880/hello-headers", + "tls": "", + "persist": false, + "proxy": "", + "authType": "", + "x": 390, + "y": 1360, + "wires": [ + [ + "65b13d57.700074" + ] + ] + }, + { + "id": "65b13d57.700074", + "type": "debug", + "z": "d41b4dd3.ecd6a", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 550, + "y": 1360, + "wires": [] + }, + { + "id": "3a62f641.2c0e8a", + "type": "template", + "z": "d41b4dd3.ecd6a", + "name": "page", + "field": "payload", + "fieldType": "msg", + "format": "html", + "syntax": "mustache", + "template": "\n \n \n

User agent: {{req.headers.user-agent}}

\n \n", + "output": "str", + "x": 430, + "y": 1260, + "wires": [ + [ + "bc626348.1496d" + ] + ] + }, + { + "id": "757fe655.e28558", + "type": "inject", + "z": "d41b4dd3.ecd6a", + "name": "", + "props": [ + { + "p": "payload" + }, + { + "p": "headers", + "v": "{\"User-Agent\":\"Node-RED\"}", + "vt": "json" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "", + "payloadType": "date", + "x": 240, + "y": 1360, + "wires": [ + [ + "7fe0fee5.f3ed7" + ] + ] + }, + { + "id": "5195095.03b4cf8", + "type": "comment", + "z": "d41b4dd3.ecd6a", + "name": "Set HTTP request header & send HTTP GET request: http://localhost:1880/hello-headers", + "info": "The field value pairs of the request headers \nyou would like to include in the message sent to the `HTTP request` node can be specified by setting `the msg.headers` field.\n\nSee Node-RED cookbook [item](https://cookbook.nodered.org/http/set-request-header) for details.", + "x": 430, + "y": 1320, + "wires": [] + } +] \ No newline at end of file diff --git a/packages/node_modules/@node-red/nodes/examples/network/http/05 - Post data to a flow.json b/packages/node_modules/@node-red/nodes/examples/network/http/05 - Post data to a flow.json new file mode 100644 index 000000000..e44ea0bdd --- /dev/null +++ b/packages/node_modules/@node-red/nodes/examples/network/http/05 - Post data to a flow.json @@ -0,0 +1,135 @@ +[ + { + "id": "69a64e3d.84da3", + "type": "http in", + "z": "d41b4dd3.ecd6a", + "name": "", + "url": "/hello-raw", + "method": "post", + "upload": false, + "swaggerDoc": "", + "x": 260, + "y": 1560, + "wires": [ + [ + "38d357a7.b69d08" + ] + ] + }, + { + "id": "43e49c36.dc7624", + "type": "http response", + "z": "d41b4dd3.ecd6a", + "name": "", + "statusCode": "", + "headers": {}, + "x": 530, + "y": 1560, + "wires": [] + }, + { + "id": "8cb4b74e.602c28", + "type": "comment", + "z": "d41b4dd3.ecd6a", + "name": "Post data to a flow", + "info": "The `HTTP In` node can listen for POST requests. It returns the posted data as `msg.payload`.\n\nSee Node-RED cookbook items(\n[post raw data(https://cookbook.nodered.org/http/post-raw-data-to-a-flow), [post form data](https://cookbook.nodered.org/http/post-form-data-to-a-flow), [post JSON data](https://cookbook.nodered.org/http/post-json-data-to-a-flow)\n) for details.", + "x": 210, + "y": 1520, + "wires": [] + }, + { + "id": "ec661b6b.c3c2b8", + "type": "http request", + "z": "d41b4dd3.ecd6a", + "name": "", + "method": "POST", + "ret": "txt", + "paytoqs": "ignore", + "url": "http://localhost:1880/hello-raw", + "tls": "", + "persist": false, + "proxy": "", + "authType": "", + "x": 370, + "y": 1660, + "wires": [ + [ + "7c2812c.c6ee7ec" + ] + ] + }, + { + "id": "7c2812c.c6ee7ec", + "type": "debug", + "z": "d41b4dd3.ecd6a", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 530, + "y": 1660, + "wires": [] + }, + { + "id": "38d357a7.b69d08", + "type": "template", + "z": "d41b4dd3.ecd6a", + "name": "page", + "field": "payload", + "fieldType": "msg", + "format": "html", + "syntax": "mustache", + "template": "\n \n \n

Hello {{payload}}

\n \n", + "output": "str", + "x": 410, + "y": 1560, + "wires": [ + [ + "43e49c36.dc7624" + ] + ] + }, + { + "id": "e45041b6.9ec13", + "type": "inject", + "z": "d41b4dd3.ecd6a", + "name": "", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "Nick", + "payloadType": "str", + "x": 230, + "y": 1660, + "wires": [ + [ + "ec661b6b.c3c2b8" + ] + ] + }, + { + "id": "af33dae7.b21138", + "type": "comment", + "z": "d41b4dd3.ecd6a", + "name": "Send HTTP POST request: http://localhost:1880/hello-raw", + "info": "", + "x": 330, + "y": 1620, + "wires": [] + } +] \ No newline at end of file diff --git a/packages/node_modules/@node-red/nodes/examples/network/http/06 - Post file to a flow.json b/packages/node_modules/@node-red/nodes/examples/network/http/06 - Post file to a flow.json new file mode 100644 index 000000000..aec360a91 --- /dev/null +++ b/packages/node_modules/@node-red/nodes/examples/network/http/06 - Post file to a flow.json @@ -0,0 +1,126 @@ +[ + { + "id": "59760c9d.172d94", + "type": "http in", + "z": "d41b4dd3.ecd6a", + "name": "", + "url": "/hello-upload", + "method": "post", + "upload": true, + "swaggerDoc": "", + "x": 270, + "y": 1980, + "wires": [ + [ + "e30073f3.ad429" + ] + ] + }, + { + "id": "d0b3e8b4.2cfde8", + "type": "comment", + "z": "d41b4dd3.ecd6a", + "name": "Post file to a flow", + "info": "The `HTTP In` node can listen for POST requests for file upload. Information for uploaded files can be accessed from `msg.req.files`.\n", + "x": 200, + "y": 1760, + "wires": [] + }, + { + "id": "a888a043.ebb72", + "type": "http in", + "z": "d41b4dd3.ecd6a", + "name": "", + "url": "/hello-upload", + "method": "get", + "upload": false, + "swaggerDoc": "", + "x": 270, + "y": 1880, + "wires": [ + [ + "14b950b.0ed5aaf" + ] + ] + }, + { + "id": "2ccb67c7.02c568", + "type": "http response", + "z": "d41b4dd3.ecd6a", + "name": "", + "statusCode": "", + "headers": {}, + "x": 590, + "y": 1880, + "wires": [] + }, + { + "id": "14b950b.0ed5aaf", + "type": "template", + "z": "d41b4dd3.ecd6a", + "name": "", + "field": "payload", + "fieldType": "msg", + "format": "html", + "syntax": "mustache", + "template": "\n \n \n
\n
\n \n \n
\n
\n \n
\n
\n \n", + "output": "str", + "x": 440, + "y": 1880, + "wires": [ + [ + "2ccb67c7.02c568" + ] + ] + }, + { + "id": "54f2edb5.62fca4", + "type": "http response", + "z": "d41b4dd3.ecd6a", + "name": "", + "statusCode": "", + "headers": {}, + "x": 590, + "y": 1980, + "wires": [] + }, + { + "id": "e30073f3.ad429", + "type": "template", + "z": "d41b4dd3.ecd6a", + "name": "", + "field": "payload", + "fieldType": "msg", + "format": "html", + "syntax": "mustache", + "template": "\n \n \n

Hello {{req.files.0.originalname}}

\n \n", + "output": "str", + "x": 440, + "y": 1980, + "wires": [ + [ + "54f2edb5.62fca4" + ] + ] + }, + { + "id": "6c3c1bf.48cc2e4", + "type": "comment", + "z": "d41b4dd3.ecd6a", + "name": "Create HTTP page for file upload: open http://localhost:1880/hello-upload \\n from Web browser. Then upload a file.", + "info": "", + "x": 440, + "y": 1820, + "wires": [] + }, + { + "id": "c6242caa.8ec63", + "type": "comment", + "z": "d41b4dd3.ecd6a", + "name": "Serve POST request for file upload", + "info": "", + "x": 320, + "y": 1940, + "wires": [] + } +] \ No newline at end of file diff --git a/packages/node_modules/@node-red/nodes/examples/network/http/07 - Working with cookies.json b/packages/node_modules/@node-red/nodes/examples/network/http/07 - Working with cookies.json new file mode 100644 index 000000000..06a209634 --- /dev/null +++ b/packages/node_modules/@node-red/nodes/examples/network/http/07 - Working with cookies.json @@ -0,0 +1,187 @@ +[ + { + "id": "c362b989.954ae8", + "type": "http in", + "z": "d41b4dd3.ecd6a", + "name": "", + "url": "/hello-cookie", + "method": "get", + "swaggerDoc": "", + "x": 250, + "y": 2200, + "wires": [ + [ + "21ddf71f.d00518" + ] + ] + }, + { + "id": "21ddf71f.d00518", + "type": "function", + "z": "d41b4dd3.ecd6a", + "name": "Format cookies", + "func": "msg.payload = JSON.stringify(msg.req.cookies,null,4);\nreturn msg;", + "outputs": 1, + "noerr": 0, + "x": 460, + "y": 2200, + "wires": [ + [ + "f3aa98c1.befc18" + ] + ] + }, + { + "id": "f3aa98c1.befc18", + "type": "template", + "z": "d41b4dd3.ecd6a", + "name": "page", + "field": "payload", + "fieldType": "msg", + "format": "html", + "syntax": "mustache", + "template": "\n \n \n

Cookies

\n Add a cookie
\n Clear cookies
\n
{{ payload }}
\n \n", + "output": "str", + "x": 650, + "y": 2200, + "wires": [ + [ + "f52e2880.180968" + ] + ] + }, + { + "id": "f52e2880.180968", + "type": "http response", + "z": "d41b4dd3.ecd6a", + "name": "", + "x": 870, + "y": 2200, + "wires": [] + }, + { + "id": "9a2a9a4.0fc0768", + "type": "change", + "z": "d41b4dd3.ecd6a", + "name": "Redirect to /hello-cookie", + "rules": [ + { + "t": "set", + "p": "statusCode", + "pt": "msg", + "to": "302", + "tot": "num" + }, + { + "t": "set", + "p": "headers", + "pt": "msg", + "to": "{}", + "tot": "json" + }, + { + "t": "set", + "p": "headers.location", + "pt": "msg", + "to": "/hello-cookie", + "tot": "str" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 670, + "y": 2260, + "wires": [ + [ + "f52e2880.180968" + ] + ] + }, + { + "id": "afefb90.53dcf48", + "type": "function", + "z": "d41b4dd3.ecd6a", + "name": "Add a cookie", + "func": "msg.cookies = { };\nmsg.cookies[\"demo-\"+(Math.floor(Math.random()*1000))] = Date.now();\nreturn msg;", + "outputs": 1, + "noerr": 0, + "x": 450, + "y": 2240, + "wires": [ + [ + "9a2a9a4.0fc0768" + ] + ] + }, + { + "id": "d5205a2c.db9018", + "type": "function", + "z": "d41b4dd3.ecd6a", + "name": "Clear cookies", + "func": "// Find demo cookies and clear them\nvar cookieNames = Object.keys(msg.req.cookies).filter(function(cookieName) { return /^demo-/.test(cookieName);});\nmsg.cookies = {};\n\ncookieNames.forEach(function(cookieName) {\n msg.cookies[cookieName] = null;\n});\n\nreturn msg;", + "outputs": 1, + "noerr": 0, + "x": 460, + "y": 2280, + "wires": [ + [ + "9a2a9a4.0fc0768" + ] + ] + }, + { + "id": "fda60c66.04975", + "type": "http in", + "z": "d41b4dd3.ecd6a", + "name": "", + "url": "/hello-cookie/add", + "method": "get", + "swaggerDoc": "", + "x": 260, + "y": 2240, + "wires": [ + [ + "afefb90.53dcf48" + ] + ] + }, + { + "id": "35285a76.1f8636", + "type": "http in", + "z": "d41b4dd3.ecd6a", + "name": "", + "url": "/hello-cookie/clear", + "method": "get", + "swaggerDoc": "", + "x": 260, + "y": 2280, + "wires": [ + [ + "d5205a2c.db9018" + ] + ] + }, + { + "id": "cb094c2f.7e34d", + "type": "comment", + "z": "d41b4dd3.ecd6a", + "name": "Working with cookies", + "info": "The messages sent by the `HTTP In` node include the `msg.req.cookies` property that lists the cookies set on the current request.\n\nThe `HTTP Response` node will use the `msg.cookies` property in order to set or clear cookies.\n\nSee Node-RED cookbook [item](https://cookbook.nodered.org/http/work-with-cookies) for details.\n", + "x": 220, + "y": 2100, + "wires": [] + }, + { + "id": "287a9146.683afe", + "type": "comment", + "z": "d41b4dd3.ecd6a", + "name": "Create HTTP page for testing cookies: open http://localhost:1880/hello-cookie from Web browser. ", + "info": "", + "x": 500, + "y": 2160, + "wires": [] + } +] \ No newline at end of file From 8306ddd40f3ec34fd555634510bd46c01fddb770 Mon Sep 17 00:00:00 2001 From: Hiroyasu Nishiyama Date: Wed, 3 Feb 2021 17:01:29 +0900 Subject: [PATCH 2/4] add examples for TCP in/out node --- .../tcp/01 - Connect to TCP out server.json | 92 +++++++++ .../tcp/02 - Connect to TCP in server.json | 92 +++++++++ ...end reply to client of TCP connection.json | 174 ++++++++++++++++++ 3 files changed, 358 insertions(+) create mode 100644 packages/node_modules/@node-red/nodes/examples/network/tcp/01 - Connect to TCP out server.json create mode 100644 packages/node_modules/@node-red/nodes/examples/network/tcp/02 - Connect to TCP in server.json create mode 100644 packages/node_modules/@node-red/nodes/examples/network/tcp/03 - Send reply to client of TCP connection.json diff --git a/packages/node_modules/@node-red/nodes/examples/network/tcp/01 - Connect to TCP out server.json b/packages/node_modules/@node-red/nodes/examples/network/tcp/01 - Connect to TCP out server.json new file mode 100644 index 000000000..78c24760c --- /dev/null +++ b/packages/node_modules/@node-red/nodes/examples/network/tcp/01 - Connect to TCP out server.json @@ -0,0 +1,92 @@ +[ + { + "id": "73874b9e.d985b4", + "type": "tcp in", + "z": "cfd9159c.6f73e8", + "name": "", + "server": "client", + "host": "localhost", + "port": "1881", + "datamode": "single", + "datatype": "utf8", + "newline": "", + "topic": "", + "base64": false, + "x": 230, + "y": 240, + "wires": [ + [ + "ce332113.d2c31" + ] + ] + }, + { + "id": "a4bd9948.dfeb58", + "type": "tcp out", + "z": "cfd9159c.6f73e8", + "host": "localhost", + "port": "1881", + "beserver": "server", + "base64": false, + "end": true, + "name": "", + "x": 390, + "y": 180, + "wires": [] + }, + { + "id": "9f80f9c7.1e3c98", + "type": "inject", + "z": "cfd9159c.6f73e8", + "name": "", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "Hello, World!", + "payloadType": "str", + "x": 210, + "y": 180, + "wires": [ + [ + "a4bd9948.dfeb58" + ] + ] + }, + { + "id": "ce332113.d2c31", + "type": "debug", + "z": "cfd9159c.6f73e8", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 410, + "y": 240, + "wires": [] + }, + { + "id": "711ed10d.1d765", + "type": "comment", + "z": "cfd9159c.6f73e8", + "name": "Connect to TCP out server", + "info": "`TCP in` node can connect to network server using tcp protocol. `TCP out` node can serve a network server using tcp procol.\n", + "x": 190, + "y": 120, + "wires": [] + } +] \ No newline at end of file diff --git a/packages/node_modules/@node-red/nodes/examples/network/tcp/02 - Connect to TCP in server.json b/packages/node_modules/@node-red/nodes/examples/network/tcp/02 - Connect to TCP in server.json new file mode 100644 index 000000000..357cbb9ca --- /dev/null +++ b/packages/node_modules/@node-red/nodes/examples/network/tcp/02 - Connect to TCP in server.json @@ -0,0 +1,92 @@ +[ + { + "id": "511f8208.c4c20c", + "type": "tcp in", + "z": "cfd9159c.6f73e8", + "name": "", + "server": "server", + "host": "localhost", + "port": "1882", + "datamode": "single", + "datatype": "utf8", + "newline": "", + "topic": "", + "base64": false, + "x": 230, + "y": 460, + "wires": [ + [ + "6b8be121.32be9" + ] + ] + }, + { + "id": "ec0bc4aa.b3c828", + "type": "tcp out", + "z": "cfd9159c.6f73e8", + "host": "localhost", + "port": "1882", + "beserver": "client", + "base64": false, + "end": true, + "name": "", + "x": 390, + "y": 400, + "wires": [] + }, + { + "id": "17cf7d56.9efb03", + "type": "inject", + "z": "cfd9159c.6f73e8", + "name": "", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "Hello, World!", + "payloadType": "str", + "x": 210, + "y": 400, + "wires": [ + [ + "ec0bc4aa.b3c828" + ] + ] + }, + { + "id": "6b8be121.32be9", + "type": "debug", + "z": "cfd9159c.6f73e8", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 410, + "y": 460, + "wires": [] + }, + { + "id": "76196665.7c23e8", + "type": "comment", + "z": "cfd9159c.6f73e8", + "name": "Connect to TCP in server", + "info": "`TCP out` node can connect to network server using tcp protocol. `TCP in` node can serve a network server using tcp procol.\n", + "x": 190, + "y": 340, + "wires": [] + } +] \ No newline at end of file diff --git a/packages/node_modules/@node-red/nodes/examples/network/tcp/03 - Send reply to client of TCP connection.json b/packages/node_modules/@node-red/nodes/examples/network/tcp/03 - Send reply to client of TCP connection.json new file mode 100644 index 000000000..b4a324261 --- /dev/null +++ b/packages/node_modules/@node-red/nodes/examples/network/tcp/03 - Send reply to client of TCP connection.json @@ -0,0 +1,174 @@ +[ + { + "id": "d9a91d7e.05f0d", + "type": "tcp in", + "z": "cfd9159c.6f73e8", + "name": "", + "server": "server", + "host": "localhost", + "port": "1883", + "datamode": "stream", + "datatype": "utf8", + "newline": "¥n", + "topic": "", + "base64": false, + "x": 230, + "y": 740, + "wires": [ + [ + "3871d8af.25e208" + ] + ] + }, + { + "id": "9fa8f09d.7591b", + "type": "inject", + "z": "cfd9159c.6f73e8", + "name": "", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "\"Hello, World!¥n\"", + "payloadType": "jsonata", + "x": 190, + "y": 640, + "wires": [ + [ + "948a8410.ab0a08" + ] + ] + }, + { + "id": "33df08b.753e9f8", + "type": "debug", + "z": "cfd9159c.6f73e8", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 710, + "y": 640, + "wires": [] + }, + { + "id": "948a8410.ab0a08", + "type": "tcp request", + "z": "cfd9159c.6f73e8", + "server": "localhost", + "port": "1883", + "out": "char", + "splitc": "\\n", + "name": "", + "x": 350, + "y": 640, + "wires": [ + [ + "f6d6be6a.efb4c" + ] + ] + }, + { + "id": "fbd442d8.cb273", + "type": "tcp out", + "z": "cfd9159c.6f73e8", + "host": "", + "port": "", + "beserver": "reply", + "base64": false, + "end": false, + "name": "", + "x": 530, + "y": 740, + "wires": [] + }, + { + "id": "3871d8af.25e208", + "type": "change", + "z": "cfd9159c.6f73e8", + "name": "set result", + "rules": [ + { + "t": "set", + "p": "payload", + "pt": "msg", + "to": "\"Received: \" & payload & \"\b\\n\"", + "tot": "jsonata" + } + ], + "action": "", + "property": "", + "from": "", + "to": "", + "reg": false, + "x": 400, + "y": 740, + "wires": [ + [ + "fbd442d8.cb273" + ] + ] + }, + { + "id": "f6d6be6a.efb4c", + "type": "function", + "z": "cfd9159c.6f73e8", + "name": "Buffer to String", + "func": "msg.payload = msg.payload.toString();\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "x": 540, + "y": 640, + "wires": [ + [ + "33df08b.753e9f8" + ] + ] + }, + { + "id": "e1412987.91dcc8", + "type": "comment", + "z": "cfd9159c.6f73e8", + "name": "Send reply to client of TCP connection", + "info": "Input message from `TCP in` node may be passed to `TCP out` node to return a reply to client.\n", + "x": 230, + "y": 580, + "wires": [] + }, + { + "id": "5f43905f.2425d", + "type": "comment", + "z": "cfd9159c.6f73e8", + "name": "↓ Accept request", + "info": "", + "x": 220, + "y": 700, + "wires": [] + }, + { + "id": "a6f57329.c87c6", + "type": "comment", + "z": "cfd9159c.6f73e8", + "name": "↓ Reply result", + "info": "", + "x": 550, + "y": 700, + "wires": [] + } +] \ No newline at end of file From 3cc6c4433f33737188ff1702dfda0c5f35816e94 Mon Sep 17 00:00:00 2001 From: Hiroyasu Nishiyama Date: Wed, 3 Feb 2021 17:12:35 +0900 Subject: [PATCH 3/4] add examples for UDP in/out node --- ...01 - Transfer data using UDP protocol.json | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 packages/node_modules/@node-red/nodes/examples/network/udp/01 - Transfer data using UDP protocol.json diff --git a/packages/node_modules/@node-red/nodes/examples/network/udp/01 - Transfer data using UDP protocol.json b/packages/node_modules/@node-red/nodes/examples/network/udp/01 - Transfer data using UDP protocol.json new file mode 100644 index 000000000..d53a05da8 --- /dev/null +++ b/packages/node_modules/@node-red/nodes/examples/network/udp/01 - Transfer data using UDP protocol.json @@ -0,0 +1,92 @@ +[ + { + "id": "73279b5.5151664", + "type": "udp in", + "z": "92236e19.9e4cb", + "name": "", + "iface": "", + "port": "1881", + "ipv": "udp4", + "multicast": "false", + "group": "", + "datatype": "utf8", + "x": 220, + "y": 220, + "wires": [ + [ + "d98b60d3.7331e" + ] + ] + }, + { + "id": "fb19b98f.d5aa58", + "type": "udp out", + "z": "92236e19.9e4cb", + "name": "", + "addr": "localhost", + "iface": "", + "port": "1881", + "ipv": "udp4", + "outport": "", + "base64": false, + "multicast": "false", + "x": 410, + "y": 160, + "wires": [] + }, + { + "id": "33f18897.35d5b8", + "type": "inject", + "z": "92236e19.9e4cb", + "name": "", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "Hello, World!", + "payloadType": "str", + "x": 230, + "y": 160, + "wires": [ + [ + "fb19b98f.d5aa58" + ] + ] + }, + { + "id": "d98b60d3.7331e", + "type": "debug", + "z": "92236e19.9e4cb", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 370, + "y": 220, + "wires": [] + }, + { + "id": "f86495aa.8a9848", + "type": "comment", + "z": "92236e19.9e4cb", + "name": "Transfer data using UDP protocol", + "info": "`UDP in` node can be used to receive data from `UDP out` node using UDP protocol.", + "x": 230, + "y": 100, + "wires": [] + } +] \ No newline at end of file From 818021e0b7dffee1ef4dd8664251f8f5998a58e4 Mon Sep 17 00:00:00 2001 From: Hiroyasu Nishiyama Date: Wed, 3 Feb 2021 17:13:56 +0900 Subject: [PATCH 4/4] add examples for websocket in/out node --- .../01 - Connect to websocket in server.json | 96 +++++++++++++++++++ .../02 - Connect to websocket out server.json | 96 +++++++++++++++++++ 2 files changed, 192 insertions(+) create mode 100644 packages/node_modules/@node-red/nodes/examples/network/websocket/01 - Connect to websocket in server.json create mode 100644 packages/node_modules/@node-red/nodes/examples/network/websocket/02 - Connect to websocket out server.json diff --git a/packages/node_modules/@node-red/nodes/examples/network/websocket/01 - Connect to websocket in server.json b/packages/node_modules/@node-red/nodes/examples/network/websocket/01 - Connect to websocket in server.json new file mode 100644 index 000000000..5abc5c223 --- /dev/null +++ b/packages/node_modules/@node-red/nodes/examples/network/websocket/01 - Connect to websocket in server.json @@ -0,0 +1,96 @@ +[ + { + "id": "13410716.69c9d9", + "type": "websocket in", + "z": "a8360b47.074ec8", + "name": "", + "server": "89db22b6.9aa36", + "client": "", + "x": 280, + "y": 180, + "wires": [ + [ + "c2541f10.59544" + ] + ] + }, + { + "id": "c2541f10.59544", + "type": "debug", + "z": "a8360b47.074ec8", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 430, + "y": 180, + "wires": [] + }, + { + "id": "6788839e.04576c", + "type": "inject", + "z": "a8360b47.074ec8", + "name": "", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "Hello, World!", + "payloadType": "str", + "x": 290, + "y": 120, + "wires": [ + [ + "438c232a.06c2cc" + ] + ] + }, + { + "id": "438c232a.06c2cc", + "type": "websocket out", + "z": "a8360b47.074ec8", + "name": "", + "server": "", + "client": "63620788.bda128", + "x": 500, + "y": 120, + "wires": [] + }, + { + "id": "c88f97a9.4410f8", + "type": "comment", + "z": "a8360b47.074ec8", + "name": "Connect to websocket in server", + "info": "`websocket out` node can connect to web socket server. `websocket in` node can serve a web socket server.\n", + "x": 290, + "y": 80, + "wires": [] + }, + { + "id": "89db22b6.9aa36", + "type": "websocket-listener", + "path": "/ws1", + "wholemsg": "false" + }, + { + "id": "63620788.bda128", + "type": "websocket-client", + "path": "ws://localhost:1880/ws1", + "tls": "", + "wholemsg": "false" + } +] \ No newline at end of file diff --git a/packages/node_modules/@node-red/nodes/examples/network/websocket/02 - Connect to websocket out server.json b/packages/node_modules/@node-red/nodes/examples/network/websocket/02 - Connect to websocket out server.json new file mode 100644 index 000000000..667af1a95 --- /dev/null +++ b/packages/node_modules/@node-red/nodes/examples/network/websocket/02 - Connect to websocket out server.json @@ -0,0 +1,96 @@ +[ + { + "id": "759c0b2b.8a0484", + "type": "websocket in", + "z": "a8360b47.074ec8", + "name": "", + "server": "", + "client": "1d80bd86.93f372", + "x": 340, + "y": 520, + "wires": [ + [ + "1f7a7454.cb65ec" + ] + ] + }, + { + "id": "1f7a7454.cb65ec", + "type": "debug", + "z": "a8360b47.074ec8", + "name": "", + "active": true, + "tosidebar": true, + "console": false, + "tostatus": false, + "complete": "false", + "statusVal": "", + "statusType": "auto", + "x": 550, + "y": 520, + "wires": [] + }, + { + "id": "aa2fe781.e92b28", + "type": "inject", + "z": "a8360b47.074ec8", + "name": "", + "props": [ + { + "p": "payload" + }, + { + "p": "topic", + "vt": "str" + } + ], + "repeat": "", + "crontab": "", + "once": false, + "onceDelay": 0.1, + "topic": "", + "payload": "Goodbye, World!", + "payloadType": "str", + "x": 300, + "y": 460, + "wires": [ + [ + "f8bdbc9b.d82dd" + ] + ] + }, + { + "id": "f8bdbc9b.d82dd", + "type": "websocket out", + "z": "a8360b47.074ec8", + "name": "", + "server": "40bd4295.3e4ecc", + "client": "", + "x": 460, + "y": 460, + "wires": [] + }, + { + "id": "c3fbc602.2e7f08", + "type": "comment", + "z": "a8360b47.074ec8", + "name": "Connect to websocket out server", + "info": "`websocket out` node can connect to web socket server. `websocket in` node can serve a web socket server.\n", + "x": 290, + "y": 420, + "wires": [] + }, + { + "id": "1d80bd86.93f372", + "type": "websocket-client", + "path": "ws://localhost:1880/ws2", + "tls": "", + "wholemsg": "false" + }, + { + "id": "40bd4295.3e4ecc", + "type": "websocket-listener", + "path": "/ws2", + "wholemsg": "false" + } +] \ No newline at end of file