-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
75 lines (53 loc) · 1.84 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
72
73
74
75
const express = require('express');
const bodyParser= require('body-parser')
const pg = require('pg')
const app = express();
const bcrypt = require('bcrypt')
var passport = require('passport');
var Sequelize = require('sequelize');
var session = require('express-session');
var port = process.env.PORT || 8080;
/// Requiring modules
var db = require('./app/models/database')
// Use application-level middleware for common functionality, including
// logging, parsing, and session handling.
app.use(require('morgan')('combined'));
app.use(require('cookie-parser')());
/// Setting the jade views
app.set('views', './views');
app.set('view engine', 'pug');
app.use(bodyParser.urlencoded({extended: true}))
app.use(express.static('./public/'));
/// Declaring the session stuff??
app.use(session({
secret: 'oh wow very secret much security',
resave: true,
saveUninitialized: false
}));
// Declaring the passport stuff
var passport = require('passport');
var facebook = require('./app/models/facebook')
app.use(passport.initialize());
app.use(passport.session());
var initPassport = require('./passport/init');
initPassport(passport);
// Using the flash middleware provided by connect-flash to store messages in session
// and displaying in templates
var flash = require('connect-flash');
app.use(flash());
// Initialize Router
var routes = require('./routes/index')(passport);
app.use('/', routes);
/// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
// ############# FACEBOOK API CALL ####################
// Using require() in ES5
// ############# GUESTY API CALL ######################
/// This part tells the app to listen to a server
var server = app.listen(port, function (){
console.log ('Blog Application listening on: ' + server.address().port)
});