-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
71 lines (61 loc) · 2.44 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
var express = require('express');
var bodyParser = require('body-parser');
var mongoose = require('mongoose');
var logger = require('morgan');
var session = require('express-session');
var MongoStore = require('connect-mongo')(session);
var config = require('./config');
var multer = require('multer');
var cookie = require('cookie-parser');
var passport = require('passport');
var cors = require('cors');
var app = express();
app.use(express.static(__dirname + '/public'));
var baseUrl = process.env.BASE_URL || 'localhost:8080';
// if(process.env.ENV === 'production') {
// app.get('*',function(req,res,next){
// if(req.headers['x-forwarded-proto']!='https')
// res.redirect(baseUrl+req.url);
// else
// next(); /* Continue to other routes if we're not redirecting */
// });
// }
// app.use(cors());
// configure app to use bodyParser()
// this will let us get the data from a POST
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
multer();
app.use(logger('dev'));
var envMongoSessionUrl = process.env.MONGO_SESSION_URI || 'mongodb://localhost:27017/seevee-sessions';
app.use(session({
secret: config.secret,
resave: true,
saveUninitialized: true,
cookie: {
secure: false
},
store: new MongoStore({
url: envMongoSessionUrl
})
}));
app.use(cookie());
app.use(passport.initialize());
app.use(passport.session());
var envMongoUrl = process.env.MONGO_URI || 'mongodb://localhost:27017/seevee';
mongoose.connect(envMongoUrl);
var port = process.env.PORT || 8080; // set our port
var router = express.Router(); // get an instance of the express Router
// Prefixes API with /api. Also directs routes to the route package
app.use('/api', require('./app/routes'));
// These are for pages if the user his the refresh button
// It will send them to the current page, not the root url
app.get('/login', function(req, res) { res.redirect('/#/login'); });
app.get('/info', function(req, res) { res.redirect('/#/info'); });
app.get('/resumes', function(req, res) { res.redirect('/#/resumes'); });
app.get('/account', function(req, res) { res.redirect('/#/account'); });
app.get('/admin', function(req, res) { res.redirect('/#/admin'); });
app.get('/pages', function(req, res) { res.redirect('/#/pages'); });
app.get('*', function(req, res) { res.redirect('/'); });
app.listen(port);
console.log('Starting app on port: ' + port);