-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
54 lines (42 loc) · 1.32 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
const express = require("express");
const expressLayouts = require('express-ejs-layouts');
const bodyParser = require("body-parser");
const mongoose = require("mongoose");
const _ = require("lodash");
require("dotenv").config();
const passport = require('passport');
const session = require('express-session');
const flash = require('express-flash');
const User = require('./models/User.js');
const { ensureAuthenticated } = require('./config/auth');
const app = express();
require('./config/passport');
const db = process.env.mongoURI;
mongoose
.connect(
db,
{ useNewUrlParser: true ,useUnifiedTopology: true}
)
.then(() => console.log('MongoDB Connected'))
.catch(err => console.log(err));
app.use(
session({
secret: process.env.secretOrKey,
resave: false,
saveUninitialized: false
})
);
app.use(flash());
app.use(passport.initialize());
app.use(passport.session());
// app.use(expressLayouts);
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({extended: true}));
app.use("/public",express.static('public'));
app.use(express.static(__dirname + '/public'));
app.use('/', require('./routes/index.js'));
// app.use('/users', require('./routes/users.js'));
// mongoose.connect(process.env.MongoDB_URL);
app.listen(3000 || process.env.PORT, function() {
console.log("Server started on port 3000");
});