-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
45 lines (37 loc) · 1.12 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
require("dotenv").config();
const express = require("express");
const PORT = process.env.PORT || 4000;
const bodyParser = require("body-parser");
const mongoose = require("mongoose");
const session = require("express-session");
const passport = require("passport");
const app = express();
//configure body parser
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(
session({
secret: process.env.MY_SECRET_KEY,
resave: false,
saveUninitialized: false,
})
);
app.use(passport.initialize()); //initialize passport to star using
app.use(passport.session()); //connect the passport w the session that have been set up
mongoose
.connect("mongodb://localhost:27017/blueDB", {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => {
console.log("Database is connected");
})
.catch((err) => {
console.log({ database_error: err });
});
mongoose.set("useCreateIndex", true);
const userRoutes = require("./api/users/routes/user"); //bring in our user routes
app.use("/user", userRoutes);
app.listen(PORT, () => {
console.log(`App is running on ${PORT}`);
});