-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
75 lines (65 loc) · 1.93 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
var express = require('express')
, util = require('util')
, fs = require('fs')
, ejs = require('ejs')
, sessions = require('cookie-sessions');
config = {
name:"piepdxb1"
, botname: "tvbot"
, track: "piepdx"
, secretkey:"25rt56g"
, twitter : {
consumerkey:"key"
, consumersecret:"secret"
, accesskey:"key"
, accesssecret:"secret"
}
}
function loadConfig() {
var env = process.env
if (!env.NODE_ENV || env.NODE_ENV == 'development'){
// desktop dev
var data = fs.readFileSync('./development.json')
try {
config = JSON.parse(data);
} catch (err) {
console.log('There has been an error parsing your config.JSON.')
console.log(err);
}
} else {
// heroku
config.secretkey = env.APPSECRET
config.twitter.consumerkey = env.TW_CONSUMERKEY
config.twitter.consumersecret = env.TW_SECRET
config.twitter.accesskey = env.TW_ACCESSKEY
config.twitter.accesssecret = env.TW_ACCESSSECRET
}
}
loadConfig()
// global app
app = express.createServer(
express.logger()
, express.bodyParser()
, sessions({secret: config.secretkey})
)
// global io
io = require('socket.io').listen(app)
//Setup the express web app config/settings: - views, templating, directories
app.configure(function(){
app.use(express.static(__dirname + '/static'));
app.set('views', __dirname + '/views');
app.register('html', require('ejs'));
app.set('view engine', 'html');
app.enable("jsonp callback");
app.use(express.cookieParser());
});
// set default layout, combined with above register "html" causes layout.html to be view
app.locals.layout = 'layout';
app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
// load the route controllers, the whole folder of them...
require('./routes');
//console.log("about to start")
app.listen(process.env.PORT || 3000);
//console.log("after start")