This repository has been archived by the owner on Dec 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
42 lines (40 loc) · 1.56 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
const
express = require('express'),
passport = require('passport'),
LocalStrategy = require('passport-local'),
passportLocalMongoose = require('passport-local-mongoose'),
bodyParser = require('body-parser'),
registerRoute = require('./routes/register'),
loginRoute = require('./routes/login'),
inputRoute = require('./routes/input'),
resultRoute= require('./routes/result');
const app = express();
const { User } = require('./models');
const port = process.env.PORT || 3000;
// =============================================================
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({extended: true}));
app.use(require('express-session')({
secret: "Saare jahaan se Acha Hindustaan hamaara",
resave: false,
saveUninitialized: false
}));
app.use(passport.initialize());
app.use(passport.session());
// =============================================================
passport.use(new LocalStrategy(User.authenticate()));
passport.serializeUser(User.serializeUser());
passport.deserializeUser(User.deserializeUser());
// =============================================================
app.use("/register", registerRoute);
app.use("/login", loginRoute);
app.use("/input", inputRoute);
app.use("/result", resultRoute);
// =============================================================
app.get("/", (req, res) => res.render('landing',{}));
app.get("/logout", (req, res) => {
req.logout();
res.redirect("/");
})
// =============================================================
app.listen(port, () => console.log('Server Online!'));