-
Notifications
You must be signed in to change notification settings - Fork 11
/
server.js
68 lines (54 loc) · 1.91 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
58
59
60
61
62
63
64
65
66
67
68
require('dotenv').load();
var express = require('express');
var bodyParser = require('body-parser')
var cookieParser = require('cookie-parser');
var session = require('express-session');
const MongoStore = require('connect-mongo')(session);
var compression = require('compression');
var favicon = require('serve-favicon');
var settings = require('./app-server/settings.js');
var port = settings.port;
var gh_clientID = settings.GHCLIENT;
var gh_secret = settings.GHSECRET;
var databaseURL = settings.dbURL;
var passport = require('passport');
var GithubStrategy = require('passport-github').Strategy;
var app = express();
app.use(compression())
// set up db
app.db = require('./app-server/dbcontroller.js'); // load our routes and pass in our app and fully configured passport
app.db.init(app, function() {
console.log('db initted');
});
app.use(cookieParser());
app.use(session({
secret: 'mysecret',
resave: true,
saveUninitialized: true,
unset: 'destroy',
store: new MongoStore({ mongooseConnection: app.mongooseConnection }),
cookie: {
maxAge: 60000000000
}
}));
app.use(passport.initialize());
app.use(passport.session());
app.use( bodyParser.json() ); // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({ // to support URL-encoded bodies
limit: '50mb',
extended: true
}));
app.enable('view cache');
// // view engine setup
app.set('views', __dirname + '/public/views')
app.set('view engine', 'jade');
app.set('view options', { basedir: process.env.__dirname})
// public static
app.use(express.static('public', { maxAge: 86400000*2 }));
app.use(favicon(__dirname + '/public/images/favicon.ico'));
// routes
require('./app-server/routes.js')(app, passport); // load our routes and pass in our app and fully configured passport
require('./app-server/login.js')(app, passport, GithubStrategy, gh_clientID, gh_secret);
app.listen(port, function(err) {
console.log('Running on port ' + port);
});