Created
January 9, 2018 04:21
-
-
Save elliotec/f74487b74d3d25de20d8e2d729aaef71 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
import express from 'express' | |
import es6Renderer from 'express-es6-template-engine' | |
import binanceApi from 'binance' | |
import http from 'http' | |
import path from 'path' | |
import socketIo from 'socket.io' | |
const state = {} | |
const binance = new binanceApi.BinanceWS() | |
const app = express() | |
const server = http.createServer(app) | |
const io = socketIo(server) | |
app.engine('html', es6Renderer) | |
app.set('views', 'views') | |
app.set('view engine', 'html') | |
app.use(express.static(path.join(__dirname, '/lib'))) | |
app.get('/', (req, res) => res.render('index', { | |
locals: { title: 'fuck', state } | |
})) | |
io.on('connection', (socket) => { | |
binance.onKline('BNBBTC', '1m', (data) => { | |
state.kline = data.kline | |
socket.emit('broadcast', { state }) | |
}) | |
}) | |
server.listen(3000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment