-
Notifications
You must be signed in to change notification settings - Fork 25
/
index.js
36 lines (29 loc) · 948 Bytes
/
index.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
const express = require("express");
const app = express();
const mongoose = require("mongoose");
const dotenv = require("dotenv");
const session = require('express-session');
dotenv.config();
const passport = require("passport");
const { loginCheck } = require("./auth/passport");
loginCheck(passport);
// Mongo DB conncetion
const database = process.env.MONGOLAB_URI;
mongoose
.connect(database, { useUnifiedTopology: true, useNewUrlParser: true })
.then(() => console.log("e don connect"))
.catch((err) => console.log(err));
app.set("view engine", "ejs");
//BodyParsing
app.use(express.urlencoded({ extended: false }));
app.use(session({
secret:'oneboy',
saveUninitialized: true,
resave: true
}));
app.use(passport.initialize());
app.use(passport.session());
//Routes
app.use("/", require("./routes/login"));
const PORT = process.env.PORT || 4111;
app.listen(PORT, console.log("Server has started at port " + PORT));