forked from xdrip-js/Lookout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·27 lines (20 loc) · 840 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env node
const express = require('express');
const socketIO = require('socket.io');
const PORT = process.env.PORT || 3000;
const server = express()
.use(express.static(__dirname + '/public'))
.use('/node_modules', express.static(__dirname + '/node_modules'))
// prevent error message on reloads as per https://stackoverflow.com/a/35284602
.get('/*', function(req, res){
res.sendFile(__dirname + '/public/index.html');
})
.listen(PORT, () => console.log(`Listening on ${ PORT }`));
const io = socketIO(server);
io.on('connection', (socket) => {
console.log('Client connected');
socket.on('disconnect', () => console.log('Client disconnected'));
});
const argv = require('yargs').argv;
const TransmitterIO = argv.sim ? require('./transmitterIO-simulated') : require('./transmitterIO')
TransmitterIO(io);