-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
43 lines (37 loc) · 1.21 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
const express = require('express');
const cors = require('cors');
const session = require('express-session');
const MongoStore = require('connect-mongo')(session);
const cookieParser = require('cookie-parser');
const logger = require('morgan');
const passport = require('passport');
const path = require('path');
const { mongoOptions } = require('./config/db');
const indexRouter = require('./routes/index');
const portfolioRouter = require('./routes/portfolio');
const featuredRouter = require('./routes/featured');
const userRouter = require('./routes/user');
const app = express();
app.use(cors(require('./config/cors')));
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(session({
secret: process.env.SECRET,
store: new MongoStore(mongoOptions),
saveUninitialized: false,
resave: false,
}));
app.use(passport.initialize());
app.use(passport.session());
app.use((req, res, next) => {
console.log(req.cookies);
next();
})
app.use('/', indexRouter);
app.use('/portfolio', portfolioRouter);
app.use('/featured', featuredRouter);
app.use('/user', userRouter);
module.exports = app;