-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
58 lines (42 loc) · 1.29 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
require('./db');
require('./auth');
require('dotenv').config();
const passport = require('passport');
const express = require('express');
const path = require('path');
const routes = require('./routes/index');
const list = require('./routes/list');
const listItem = require('./routes/list-item');
const productview = require('./routes/product-view');
const profile = require('./routes/profile');
const flash = require('connect-flash');
const app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'hbs');
// enable sessions
const session = require('express-session');
const sessionOptions = {
secret: '(store this elsewhere!)',
resave: true,
saveUninitialized: true
};
app.use(session(sessionOptions));
app.use(express.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'public')));
// passport setup
app.use(passport.initialize());
app.use(passport.session());
// app.use(flash());
// make user data available to all templates
app.use((req, res, next) => {
res.locals.user = req.user;
next();
});
app.use('/', routes);
app.use('/list', list);
app.use('/product-view',productview);
app.use('/list-item', listItem);
app.use('/profile', profile);
const port = process.env.PORT || 3000;
app.listen(port);