Last active
March 25, 2022 12:10
-
-
Save bletvaska/6856c341e580991a8bc928fb03b22171 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { | |
| "id": "3a8de455af8118df", | |
| "type": "tab", | |
| "label": "Simple Weather Service", | |
| "disabled": false, | |
| "info": "", | |
| "env": [] | |
| }, | |
| { | |
| "id": "fd7f56ebceb26a3c", | |
| "type": "http in", | |
| "z": "3a8de455af8118df", | |
| "name": "", | |
| "url": "/api/weather/:city", | |
| "method": "get", | |
| "upload": false, | |
| "swaggerDoc": "", | |
| "x": 140, | |
| "y": 80, | |
| "wires": [ | |
| [ | |
| "e317d4b570e0712a" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "5360ebd931e9d839", | |
| "type": "http response", | |
| "z": "3a8de455af8118df", | |
| "name": "", | |
| "statusCode": "", | |
| "headers": {}, | |
| "x": 670, | |
| "y": 440, | |
| "wires": [] | |
| }, | |
| { | |
| "id": "6f5888dde79d8f42", | |
| "type": "template", | |
| "z": "3a8de455af8118df", | |
| "name": "prepare response", | |
| "field": "payload", | |
| "fieldType": "msg", | |
| "format": "handlebars", | |
| "syntax": "mustache", | |
| "template": "{\n \"city\": \"{{ req.params.city }}\",\n \"temp\": {{ payload.main.temp }},\n \"pressure\": {{ payload.main.pressure }},\n \"humidity\": {{ payload.main.humidity }},\n \"dt\": {{ payload.dt }}\n}", | |
| "output": "json", | |
| "x": 130, | |
| "y": 300, | |
| "wires": [ | |
| [ | |
| "d3cac6d815d616c8" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "cf8387684f4d6aed", | |
| "type": "http request", | |
| "z": "3a8de455af8118df", | |
| "name": "get weather", | |
| "method": "GET", | |
| "ret": "obj", | |
| "paytoqs": "ignore", | |
| "url": "https://api.openweathermap.org/data/2.5/weather?q={{ req.params.city }}&appid=08f5d8fd385c443eeff6608c643e0bc5&units={{ req.query.units }}", | |
| "tls": "", | |
| "persist": false, | |
| "proxy": "", | |
| "authType": "", | |
| "senderr": false, | |
| "x": 710, | |
| "y": 80, | |
| "wires": [ | |
| [ | |
| "6f5888dde79d8f42" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "61d5aac7fdfa2ef5", | |
| "type": "function", | |
| "z": "3a8de455af8118df", | |
| "name": "", | |
| "func": "if(!msg.req.query.hasOwnProperty('units') ){\n msg.req.query.units = 'metrics';\n}\n\nreturn msg;", | |
| "outputs": 1, | |
| "noerr": 0, | |
| "initialize": "", | |
| "finalize": "", | |
| "libs": [], | |
| "x": 520, | |
| "y": 120, | |
| "wires": [ | |
| [] | |
| ] | |
| }, | |
| { | |
| "id": "e317d4b570e0712a", | |
| "type": "switch", | |
| "z": "3a8de455af8118df", | |
| "name": "", | |
| "property": "req.query.units", | |
| "propertyType": "msg", | |
| "rules": [ | |
| { | |
| "t": "null" | |
| }, | |
| { | |
| "t": "else" | |
| } | |
| ], | |
| "checkall": "true", | |
| "repair": false, | |
| "outputs": 2, | |
| "x": 350, | |
| "y": 80, | |
| "wires": [ | |
| [ | |
| "b34cec002dd929ac" | |
| ], | |
| [ | |
| "cf8387684f4d6aed" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "b34cec002dd929ac", | |
| "type": "change", | |
| "z": "3a8de455af8118df", | |
| "name": "set default units", | |
| "rules": [ | |
| { | |
| "t": "set", | |
| "p": "req.query.units", | |
| "pt": "msg", | |
| "to": "metric", | |
| "tot": "str" | |
| }, | |
| { | |
| "t": "set", | |
| "p": "payload", | |
| "pt": "msg", | |
| "to": "hello", | |
| "tot": "str" | |
| } | |
| ], | |
| "action": "", | |
| "property": "", | |
| "from": "", | |
| "to": "", | |
| "reg": false, | |
| "x": 520, | |
| "y": 40, | |
| "wires": [ | |
| [ | |
| "cf8387684f4d6aed" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "263e06800f8c3a5f", | |
| "type": "xml", | |
| "z": "3a8de455af8118df", | |
| "name": "", | |
| "property": "payload", | |
| "attr": "", | |
| "chr": "", | |
| "x": 290, | |
| "y": 400, | |
| "wires": [ | |
| [ | |
| "d23694b09d3c59d3" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "79a0bfa762ab8e8e", | |
| "type": "yaml", | |
| "z": "3a8de455af8118df", | |
| "property": "payload", | |
| "name": "", | |
| "x": 290, | |
| "y": 360, | |
| "wires": [ | |
| [ | |
| "961ba07f2d0ba3e1" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "d3cac6d815d616c8", | |
| "type": "switch", | |
| "z": "3a8de455af8118df", | |
| "name": "", | |
| "property": "req.headers.accept", | |
| "propertyType": "msg", | |
| "rules": [ | |
| { | |
| "t": "eq", | |
| "v": "text/yaml", | |
| "vt": "str" | |
| }, | |
| { | |
| "t": "eq", | |
| "v": "application/xml", | |
| "vt": "str" | |
| }, | |
| { | |
| "t": "else" | |
| } | |
| ], | |
| "checkall": "true", | |
| "repair": false, | |
| "outputs": 3, | |
| "x": 110, | |
| "y": 420, | |
| "wires": [ | |
| [ | |
| "79a0bfa762ab8e8e" | |
| ], | |
| [ | |
| "263e06800f8c3a5f" | |
| ], | |
| [ | |
| "5360ebd931e9d839" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "961ba07f2d0ba3e1", | |
| "type": "change", | |
| "z": "3a8de455af8118df", | |
| "name": "set Content-Type", | |
| "rules": [ | |
| { | |
| "t": "set", | |
| "p": "headers.content-type", | |
| "pt": "msg", | |
| "to": "text/yaml", | |
| "tot": "str" | |
| } | |
| ], | |
| "action": "", | |
| "property": "", | |
| "from": "", | |
| "to": "", | |
| "reg": false, | |
| "x": 470, | |
| "y": 360, | |
| "wires": [ | |
| [ | |
| "5360ebd931e9d839" | |
| ] | |
| ] | |
| }, | |
| { | |
| "id": "d23694b09d3c59d3", | |
| "type": "change", | |
| "z": "3a8de455af8118df", | |
| "name": "set Content-Type", | |
| "rules": [ | |
| { | |
| "t": "set", | |
| "p": "headers.content-type", | |
| "pt": "msg", | |
| "to": "application/xml", | |
| "tot": "str" | |
| } | |
| ], | |
| "action": "", | |
| "property": "", | |
| "from": "", | |
| "to": "", | |
| "reg": false, | |
| "x": 470, | |
| "y": 400, | |
| "wires": [ | |
| [ | |
| "5360ebd931e9d839" | |
| ] | |
| ] | |
| } | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment