-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathLogicPull.js
More file actions
93 lines (76 loc) · 3.02 KB
/
LogicPull.js
File metadata and controls
93 lines (76 loc) · 3.02 KB
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
84
85
86
87
88
89
90
91
92
93
/* Copyright 2015 Chris Zieba
This program is free software: you can redistribute it and/or modify it under the terms of the GNU
Affero General Public License as published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU Affero General Public License for more details. You should have received a
copy of the GNU Affero General Public License along with this program. If not, see
<http://www.gnu.org/licenses/>.
*/
var express = require('express'),
app = module.exports = express(),
MongoStore = require('connect-mongo')(express),
server = require('http').createServer(app),
fs = require('fs'),
socket = require('./lib/sockets'),
flash = require('./middleware/flash'),
version = require('./package.json').version,
config = require('./config');
// Set the development variables
app.configure('development', function () {
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
// Add in all the config settings
for(var setting in config.development) {
app.set(setting, config.development[setting]);
}
});
// Set the production variables
app.configure('production', function () {
app.use(express.errorHandler());
for(var setting in config.production) {
app.set(setting, config.production[setting]);
}
});
// set up the sessions to use the mongo database
var sessionStore = new MongoStore({
url: 'mongodb://' + app.get('mongo_host') + ':' + app.get('mongo_port') + '/' + app.get('mongo_db'),
autoReconnect: true
});
// these settings are common to both environments
app.configure(function () {
app.use(express.favicon(__dirname + '/public/favicon.ico'));
app.engine('.html', require('ejs').__express);
app.set('views', __dirname + '/views/site');
// Without this you would need to supply the extension to res.render()
app.set('view engine', 'ejs');
// used in CSS and JavaScript as query string
app.set('version', version);
app.use(express.cookieParser());
app.use(express.bodyParser());
app.use(express.methodOverride());
// This attaches the session to the req object
app.use(express.session({
store: sessionStore,
secret: app.get('session_secret'),
cookie: {
path: app.get('cookie_path'),
httpOnly: app.get('cookie_http_only'),
maxAge: app.get('cookie_max_age'),
secure: app.get('cookie_secure'),
domain: app.get('base_vhost')
}
}));
app.use(express.csrf());
// Generate a token for the form...the form input must be created
app.use(function(req, res, next) {
res.locals.token = req.csrfToken();
next();
});
app.use(flash());
app.use(app.router);
app.use(express.vhost(app.get('base_vhost'), require('./subdomains/LogicPull')));
});
// run the server with websockets
server.listen(app.get('server_port'));
socket.listen(server, sessionStore, app);