-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·73 lines (61 loc) · 2.25 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
const path = require('path');
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
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');
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('/explore').get(function(req, res) {
return res.sendFile(path.join(__dirname, './backend/static/index.html'));
});
app.route('/detail').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('/profile').get(function(req,res) {
return res.sendFile(path.join(__dirname, './backend/static/index.html'));
})
app.route('/profile/:id').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'));
})
/* 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));
/* =========================================================================== */
// dynamic binding
const PORT = process.env.PORT || 3000;
// start the server
app.listen(PORT, () => {
console.log('Server is running on PORT ' + PORT );
});