-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
58 lines (45 loc) · 1.24 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* jshint -W097 */
/* global __dirname: false */
'use strict';
var express = require('express');
var app = express();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var ps = require('powersocket');
var https = require('https');
var url = require('url');
var request = require('request');
var port = process.env.MENTION_PORT || 3000;
ps.Connection({
url: process.env.POWERSOCKET_URL,
onTweet: function(tweet) {
io.sockets.emit('tweet', tweet);
}
});
io.on('connection', function(socket) {
console.log('Got a client');
socket.on('config', function(config) {
io.sockets.emit('config', config);
});
});
app.use(express.static('public'));
app.use(express.static('bower_components'));
app.get('/', function(req, res){
res.sendFile(__dirname + '/index.html');
});
app.get('/vis', function(req, res){
res.sendFile(__dirname + '/vis.html');
});
app.get('/controls', function(req, res) {
res.sendFile(__dirname + '/controls.html');
});
app.get('/orbs', function(req, res) {
res.sendFile(__dirname + '/orbs.html');
});
app.get('/image', function(req, res) {
var imgUrl = url.parse(req.query.q);
request(imgUrl.href).pipe(res);
});
http.listen(port, function(){
console.log('listening on *:' + port);
});