-
Notifications
You must be signed in to change notification settings - Fork 3
/
server.js
50 lines (39 loc) · 1.35 KB
/
server.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
const express = require('express');
const session = require('express-session');
const app = express();
const mongoose = require('mongoose');
const passport = require('passport');
const bcrypt = require('bcryptjs');
const flash = require('connect-flash');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const configDB = require('./config/database.js');
if(typeof configDB.url === 'undefined'){
console.log('================================================================');
console.log(' This appears to be your first time running Paige');
console.log(' Please configure your database in the config/database.js file');
console.log('================================================================');
process.exit();
}
mongoose.Promise = global.Promise;
mongoose.connect(configDB.url);
require('./config/passport')(passport);
app.use(express.static('app'));
app.use(cookieParser());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.set('view engine', 'pug');
app.use(session({
secret: 'ceiling cat',
resave: true,
saveUninitialized: true
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());
require('./app/routes.js')(app, passport);
app.listen(process.env.PORT || 8080, function() {
console.log('Server started at http://localhost:8080');
});