-
Notifications
You must be signed in to change notification settings - Fork 5
/
_bkup.js
62 lines (42 loc) · 1.79 KB
/
_bkup.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
// set up ========================
var compass = require('compass');
var express = require('express');
var app = express();
var mongoose = require('mongoose');
var passport = require('passport');
var io = require('socket.io');
// database =================
var db = require('./config/db')[process.env.NODE_ENV || 'development'];
var port = Number(process.env.PORT || 5000);
mongoose.connect(db.url);
// requires =================
require('./config/passport')(passport); // pass passport for configuration
// configuration =================
app.configure(function() {
// Express.
app.use(express.static(__dirname + '/public')); // set the static files location /public/img will be /img for users
app.use(express.logger('dev')); // log every request to the console
app.use(express.bodyParser()); // pull information from html in POST
app.use(express.cookieParser());
app.use(express.methodOverride()); // simulate DELETE and PUT
app.use(express.session({ secret: 'imgonnaaskawayeverything', cookie: { httpOnly: false } })); // session secret
// Compass.
app.use(compass({ cwd: __dirname + '/public' }));
// Passport.
app.use(passport.initialize());
app.use(passport.session()); // persistent login sessions
});
var https = require('https');
var http = require('http');
http.globalAgent.maxSockets = 100;
https.globalAgent.maxSockets = 100;
// routes ==================================================
require('./app/routes')(app, passport);
var socket = require('./app/socket.js');
// listen (start app with node server.js) ======================================
var io = require('socket.io').listen(app.listen(port));
io.configure(function () {
io.set('transports');
});
io.sockets.on('connection', socket);
exports = module.exports = app;