-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
88 lines (68 loc) · 2.2 KB
/
index.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
84
85
86
87
88
var path = require('path'),
http = require('http'),
config = require('config'),
express = require('express'),
bodyParser = require('body-parser'),
uuid = require('uuid'),
cookieParser = require('cookie-parser'),
methodOverride = require('method-override'),
multipart = require('connect-multiparty'),
multipartMiddleware = multipart(),
mongoose = require('mongoose'),
morgan = require('morgan'),
multiparty = require('multiparty'),
expressValidator = require('express-validator'),
session = require('express-session'),
flash = require('connect-flash'),
routes = require('./app/routes/routes'),
collection = require('./app/models/model'),
cookieSession = require('cookie-session');
// process.env.PORT = 5000;
var app = module.exports = express();
mongoose.connect('mongodb://heroku_xxgmmxtk:[email protected]:25902/heroku_xxgmmxtk', function(err) {
if (err) {
console.log('Could not connect to MongoDB!');
}
});
// connect mongDB
// mongoose.connect('mongodb://localhost/perfect-job-placement');
// ExpressJS Configuration
// app.set('port', process.env.PORT || 5000);
app.set('views', __dirname + '/app/views');
app.set('view engine', 'html');
app.engine('html', require('hbs').__express);
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(expressValidator());
app.use(bodyParser.json({limit:'100mb'}));
app.use(cookieParser());
app.use(methodOverride());
app.use(cookieSession({
name: 'session',
keys: ['d88d8d8d898d89d89d989d889x98x89x89x8989898898a8a8a8a8a8a8a'],
maxAge: 24 * 60 * 60 * 1000 // 24 hours
}))
app.use(flash());
app.use(function(req, res, next) {
if(req.session && req.session.user) {
req.user = req.session.user;
req.session.user = req.user;
}
next();
});
if(process.env.NODE_ENV == 'developement') {
app.use(express.static(path.join(__dirname, 'public')));
} else {
app.use(express.static(path.join(__dirname, 'public'), {
maxAge: '7d'
}));
}
app.use('/', routes);
/**
* Server connection..
*/
var server = http.createServer(app);
server.listen(process.env.PORT || 5000, function() {
console.log("Express server listening on port 5000");
});