-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
49 lines (37 loc) · 1.35 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
const express = require('express'),
app = express(),
ejs = require('ejs'),
mongoose = require('mongoose'),
seedDB = require('./seed'),
bodyParser = require('body-parser'),
passport = require('passport'),
localStrategy = require('passport-local'),
User = require('./models/user'),
methodOverride = require('method-override');
app.set('view engine', 'ejs');
app.use(methodOverride('_method'));
app.use(bodyParser.urlencoded({extended:true}));
app.use(express.static(__dirname + '/public'));
app.use(express.static(__dirname + '/dist'));
// PASSPORT
app.use(require('express-session')({
secret: "Time is fun",
resave: false,
saveUnitialized: false
}));
app.use(passport.initialize());
app.use(passport.session());
passport.use(new localStrategy(User.authenticate()));
passport.serializeUser(User.serializeUser());
passport.deserializeUser(User.deserializeUser());
// MONGODB
mongoose.connect(process.env.DATABASEURL || 'mongodb://localhost/project');
// seedDB();
// ROUTES
const indexRoutes = require('./routes/index');
const projectRoutes = require('./routes/projects');
app.use('/', indexRoutes);
app.use('/projects', projectRoutes);
app.listen(process.env.PORT || 8888, process.env.IP, () => {
console.log('app online');
});