/
basics.json
1 lines (1 loc) · 5.95 KB
/
basics.json
1
[{"id":"885ba1a8cdef34f9","type":"tab","label":"axios basics","disabled":false,"info":"","env":[]},{"id":"3c1c3db85b422c68","type":"http in","z":"885ba1a8cdef34f9","name":"","url":"/timestamp","method":"get","upload":false,"swaggerDoc":"","x":200,"y":100,"wires":[["45f5528c0dfcf538"]]},{"id":"bebaf3299a4d8150","type":"http response","z":"885ba1a8cdef34f9","name":"","statusCode":"","headers":{},"x":570,"y":100,"wires":[]},{"id":"45f5528c0dfcf538","type":"function","z":"885ba1a8cdef34f9","name":"set timestamp","func":"msg.payload = {ts: new Date().toISOString() };\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":100,"wires":[["bebaf3299a4d8150"]]},{"id":"8df8b5e18c565c58","type":"inject","z":"885ba1a8cdef34f9","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":170,"y":140,"wires":[["60050da81a472f25"]]},{"id":"7df6a638080d3fbc","type":"debug","z":"885ba1a8cdef34f9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":550,"y":140,"wires":[]},{"id":"60050da81a472f25","type":"axios-request","z":"885ba1a8cdef34f9","name":"","endpoint":"a45cedffe9f343a9","method":"get","url":"/timestamp","responseType":"json","keepAlive":false,"timeout":30000,"x":360,"y":140,"wires":[["7df6a638080d3fbc"]]},{"id":"c27b5c3a09f02a74","type":"http in","z":"885ba1a8cdef34f9","name":"","url":"/order","method":"post","upload":false,"swaggerDoc":"","x":190,"y":260,"wires":[["a7a47a4b6e3b1164"]]},{"id":"364fa84f6de3c115","type":"inject","z":"885ba1a8cdef34f9","name":"inject dummy order","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"products\":[\"Pizza\",\"Fish\",\"Apple\"]}","payloadType":"json","x":210,"y":300,"wires":[["30e92e3fb010db8d"]]},{"id":"8d1d3d5f72b00086","type":"debug","z":"885ba1a8cdef34f9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":300,"wires":[]},{"id":"30e92e3fb010db8d","type":"axios-request","z":"885ba1a8cdef34f9","name":"post order","endpoint":"a45cedffe9f343a9","method":"post","url":"/order","responseType":"json","keepAlive":false,"timeout":30000,"validateStatus":false,"x":440,"y":300,"wires":[["8d1d3d5f72b00086"]]},{"id":"a7a47a4b6e3b1164","type":"function","z":"885ba1a8cdef34f9","name":"receive order","func":"const orderList = flow.get('orders') || [];\nconst newOrder = {\n id: orderList.length + 1,\n ... msg.payload\n};\n\n// push new order to flow context\norderList.push(newOrder);\nflow.set('orders', orderList);\n\n// response with new order id\nmsg.payload = { id: newOrder.id };\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":260,"wires":[["53255052f9eb674d"]]},{"id":"53255052f9eb674d","type":"http response","z":"885ba1a8cdef34f9","name":"","statusCode":"","headers":{},"x":650,"y":260,"wires":[]},{"id":"4c9bcaf4c47019ae","type":"inject","z":"885ba1a8cdef34f9","name":"request order id \"1\"","props":[{"p":"params","v":"{\"id\": 1}","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":210,"y":480,"wires":[["bdc9fb11bb6d6b77"]]},{"id":"41081582f4ac4e11","type":"debug","z":"885ba1a8cdef34f9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":650,"y":480,"wires":[]},{"id":"bdc9fb11bb6d6b77","type":"axios-request","z":"885ba1a8cdef34f9","name":"request order","endpoint":"a45cedffe9f343a9","method":"get","url":"/order","responseType":"json","keepAlive":false,"timeout":30000,"validateStatus":true,"x":470,"y":480,"wires":[["41081582f4ac4e11"]]},{"id":"94fcc52873ba46cc","type":"http in","z":"885ba1a8cdef34f9","name":"","url":"/order","method":"get","upload":false,"swaggerDoc":"","x":180,"y":400,"wires":[["fcd0fb38483838fd"]]},{"id":"fcd0fb38483838fd","type":"function","z":"885ba1a8cdef34f9","name":"fetch order","func":"msg.payload = null;\n\nif(!msg.req.query.id) {\n msg.payload = \"missing query param 'id'\";\n msg.statusCode = 400;\n return msg;\n}\n\nconst orderList = flow.get('orders') || [];\nconst orderId = Number(msg.req.query.id);\nconst order = orderList.find((order)=>(order.id === orderId));\nif(order){\n msg.payload = order;\n msg.statusCode = 200;\n}else{\n msg.payload = null;\n msg.statusCode = 204;\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":400,"wires":[["f88d775dbe2b3968"]]},{"id":"f88d775dbe2b3968","type":"http response","z":"885ba1a8cdef34f9","name":"","statusCode":"","headers":{},"x":530,"y":400,"wires":[]},{"id":"3a2f6b2339cb8d47","type":"inject","z":"885ba1a8cdef34f9","name":"request order id \"9000\"","props":[{"p":"params","v":"{\"id\": 9000}","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":220,"y":540,"wires":[["bdc9fb11bb6d6b77"]]},{"id":"546e3c73cdf0eb66","type":"comment","z":"885ba1a8cdef34f9","name":"example order api","info":"","x":200,"y":220,"wires":[]},{"id":"9b785cb4ecfda313","type":"inject","z":"885ba1a8cdef34f9","name":"bad request","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":190,"y":600,"wires":[["bdc9fb11bb6d6b77"]]},{"id":"dbb5f338493901e9","type":"catch","z":"885ba1a8cdef34f9","name":"","scope":null,"uncaught":false,"x":460,"y":560,"wires":[["76e267be2828d33b"]]},{"id":"76e267be2828d33b","type":"debug","z":"885ba1a8cdef34f9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":610,"y":560,"wires":[]},{"id":"92afcce9034eac93","type":"comment","z":"885ba1a8cdef34f9","name":"example timestamp api","info":"","x":220,"y":60,"wires":[]},{"id":"a45cedffe9f343a9","type":"axios-endpoint","name":"","baseURL":"http://localhost:1880","caCertPath":"","rejectUnauthorized":true,"proxyEnabled":false,"proxyProtocol":"https","proxyHost":"","proxyPort":""}]