Skip to content

Instantly share code, notes, and snippets.

@elliotec
Created January 9, 2018 04:21
Show Gist options
  • Save elliotec/f74487b74d3d25de20d8e2d729aaef71 to your computer and use it in GitHub Desktop.
Save elliotec/f74487b74d3d25de20d8e2d729aaef71 to your computer and use it in GitHub Desktop.
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