-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
80 lines (69 loc) · 2.76 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
const path = require('path');
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const passport = require('passport')
const config = require('./config');
const User = require('./')
const router = express.Router();
const cookieSession = require('cookie-session');
const cookieParser = require('cookie-parser');
// var allowCrossDomain = function (req, res, next) {
// res.header("Access-Control-Allow-Origin", "*");
// res.header("Access-Control-Allow-Headers", "X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept");
// res.header("Access-Control-Allow-Methods", "POST, GET, PUT, DELETE, OPTIONS");
// next();
// };
// app.use(allowCrossDomain);
app.use(express.static('./backend/static/'));
app.use(express.static('./frontend/dist/'));
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
// Static routes
app.route('/').get(function(req, res) {
return res.sendFile(path.join(__dirname, './backend/static/index.html'));
});
app.route('/login').get(function(req, res) {
return res.sendFile(path.join(__dirname, './backend/static/index.html'));
});
app.route('/register').get(function(req, res) {
return res.sendFile(path.join(__dirname, './backend/static/index.html'));
});
app.route('/dashboard').get(function(req,res) {
return res.sendFile(path.join(__dirname, './backend/static/index.html'));
});
app.route('/Driver').get(function(req,res) {
return res.sendFile(path.join(__dirname, './backend/static/index.html'));
});
app.route('/Passenger').get(function(req,res) {
return res.sendFile(path.join(__dirname, './backend/static/index.html'));
});
app.route('/About').get(function(req,res) {
return res.sendFile(path.join(__dirname, './backend/static/index.html'));
});
app.route('/Request').get(function(req,res) {
return res.sendFile(path.join(__dirname, './backend/static/index.html'));
});
/* New things ================================================================ */
require('./backend/models').connect(config.dbUri);
require('./backend/auth/passport')(passport);
// Initialize cookie sessions
app.use(cookieParser());
app.use(cookieSession({
keys: ['asdf', 'asdf']
}));
// Initialize Passport
app.use(passport.initialize()); // Create an instance of Passport
app.use(passport.session());
// Get our routes
app.use('/api', require('./backend/routes/api')(router, passport));
var rideInfo = require('./backend/routes/rideInfo');
app.use('/api/rideInfo', rideInfo)
/* =========================================================================== */
// start the server//cant run local
app.listen(process.env.PORT || 3000, 'fa17-cs411-37.cs.illinois.edu');
// app.listen(3000, () => {
// console.log('Server is running on http://localhost:3000 or http://127.0.0.1:3000');
// });