diff options
| author | Adam Soltys <[email protected]> | 2019-09-15 23:05:26 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2019-09-15 23:05:26 -0700 |
| commit | 765c6a42135b9334b616c26b22c816edd06e382a (patch) | |
| tree | 05da4f343358fb5e9a9083e348783f0fab973dd8 /binance.js | |
| parent | 087fdd27f3683a1deb9376b7a72aa608e6fd8e6a (diff) | |
| download | coinos-server-765c6a42135b9334b616c26b22c816edd06e382a.tar.gz coinos-server-765c6a42135b9334b616c26b22c816edd06e382a.zip | |
refactor
Diffstat (limited to 'binance.js')
| -rw-r--r-- | binance.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/binance.js b/binance.js new file mode 100644 index 00000000..8edcc5da --- /dev/null +++ b/binance.js @@ -0,0 +1,14 @@ +const WebSocket = require("ws"); + +module.exports = app => { + const binance = new WebSocket( + "wss://stream.binance.com:9443/ws/btcusdt@ticker" + ); + + binance.onmessage = async function(event) { + let msg = JSON.parse(event.data); + app.set("bid", msg.b); + app.set("ask", msg.a); + app.set("last", msg.l); + }; +}; |
