-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
30 lines (26 loc) · 788 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
const express = require("express");
const cors = require("cors");
const PORT = 8080;
const app = express();
const connectionDB = require("./config/db");
// Import of Routes
const userRoutes = require("./controllers/user.controller");
const blogRoutes = require("./controllers/blog.controller");
const commentRoutes = require("./controllers/comment.controller");
//middleware
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(cors());
//routes end point
app.use("/users", userRoutes);
app.use("/blogs", blogRoutes);
app.use("/comments", commentRoutes);
//server connection
app.listen(PORT, async () => {
try {
console.log(`Server is running on Port ${PORT}`);
await connectionDB();
} catch (error) {
console.log({ msg: error });
}
});