-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
49 lines (39 loc) · 1.2 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
require("dotenv").config();
const express = require('express');
const MongoStore = require("connect-mongo");
const session = require("express-session");
const passport = require('passport');
const flash = require('connect-flash');
const bodyParser = require('body-parser');
require("./config/passport");
require("./db");
const app = express();
require("./config")(app);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(session({
secret: process.env.SESSION_SECRET || "secret key",
resave: false,
saveUninitialized: true,
store: MongoStore.create({
mongoUrl: process.env.MONGO_URI || "mongodb://localhost:27017/echoes",
}),
cookie: {
secure: false,
httpOnly: true,
maxAge: 24 * 60 * 60 * 1000
}
}));
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());
const indexRouter = require('./routes/index');
const authRouter = require('./routes/auth/index');
const apiRouter = require('./routes/api');
// const usersRouter = require('./routes/users');
app.use('/', indexRouter);
app.use('/auth', authRouter);
app.use('/api', apiRouter);
// app.use('/users', usersRouter);
require("./error-handling")(app);
module.exports = app;