forked from nipekbless/Blogging_app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (24 loc) · 809 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
const express = require ("express")
const app = express()
require("dotenv").config()
const mongoose = require("mongoose")
const AuthRoute = require("./router/AuthRoute")
const passport = require("passport")
const BlogRoute = require("./router/BlogRoute")
const PORT = process.env.PORT_NUM || 8000
app.use(express.json())
app.use(passport.initialize())
require("./middleware/authMiddleware")(passport)
app.use("/Api" , AuthRoute)
app.use("/Api", BlogRoute)
mongoose.connect(process.env.DATABASE_URL)
mongoose.connection.on("connected", () => {
console.log("Connected to MongoDB Successfully");
});
mongoose.connection.on("error", (err) => {
console.log("An error occurred while connecting to MongoDB");
console.log(err);
});
app.listen(PORT , ()=>{
console.log(`Server running successfully`)
})