-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.js
83 lines (66 loc) · 2.03 KB
/
app.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
var http = require('http'),
nko = require('nko')('0Fpe8yXwL+6WOR2s');
/*
* Module dependencies.
*/
var express = require('express'),
app = module.exports = express.createServer();
var querystring = require('querystring'),
RedisStore = require('connect-redis')(express);
var Rooms = require('./classes/rooms');
var ui = function(req, res, next) {
res.local("scripts", []);
res.local("stylesheets", []);
next();
};
app.configure(function(){
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(ui);
app.use(express.bodyParser());
app.use(express.methodOverride());
//oauth setup
//app.use(express.logger());
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use( express.session( { secret: "oiwugrekudbhkjngh9843yt6", store: new RedisStore }));
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});
app.dynamicHelpers({
base: function(){
return '/' == app.route ? '' : app.route;
},
session: function(req, res){
return req.session;
}
});
// Configuration
var server_port = 80,
server_host = 'knockout.crunchtune.com',
api_key = 'nb7uwguu2k2ra3dy5s2qpjkr',
api_shared = 'ns3NR8ZGVG';
app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
server_port = 3002;
server_host = 'dev.crunchtune.com'
api_key = 'k7asxsy9cqsph3j9zxzmq9z8';
api_shared = 'fGerbhySxa';
});
app.configure('production', function(){
app.use(express.errorHandler());
});
//setup rdio
var rdio = require('rdio')({
rdio_api_key: api_key, //nb7uwguu2k2ra3dy5s2qpjkr
rdio_api_shared: api_shared, // ns3NR8ZGVG
callback_url: "http://"+server_host+":"+server_port+"/oauth/callback"
});
//data
var rooms = new Rooms();
//routes
require('./routes')(app, rooms, rdio, server_host);
require('./api')(app, rdio);
require('./socket')(app, rooms, rdio, server_host);
app.listen(server_port);
console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);