-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
29 lines (23 loc) · 811 Bytes
/
server.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
28
29
var http = require('http');
var path = require('path');
var express = require('express');
var bodyParser = require("body-parser");
var socketio = require('socket.io');
var tripSearcher = require('./tripSearcher.js');
var router = express();
var server = http.createServer(router);
var io = socketio.listen(server);
//Direct browsing to client directory
router.use(express.static(path.resolve(__dirname, 'client')));
router.use(bodyParser.urlencoded({
extended:true
}));
io.on('connection', function(socket) {
socket.on('getTrips', function(params) {
tripSearcher.getTrips(params, socket);
});
});
server.listen(process.env.PORT || 3000, process.env.IP || "0.0.0.0", function(){
var addr = server.address();
console.log("Citibike mapper listening at ", addr.address + ":" + addr.port);
});