-
Notifications
You must be signed in to change notification settings - Fork 27
/
index.js
42 lines (36 loc) · 1.19 KB
/
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
37
38
39
40
41
42
const express = require("express");
const mongoose = require("mongoose");
const port = process.env.PORT || 5000;
const app = express();
mongoose.connect(
"mongodb+srv://BlogUser:jAVhPqR9YORwjwXW@cluster0-fc8do.gcp.mongodb.net/BlogDB?retryWrites=true&w=majority",
{
useNewUrlParser: true,
useCreateIndex: true,
useUnifiedTopology: true,
}
);
const connection = mongoose.connection;
connection.once("open", () => {
console.log("MongoDb connected");
});
//middleware
app.use("/uploads", express.static("uploads"));
app.use(express.json());
const userRoute = require("./routes/user");
app.use("/user", userRoute);
const profileRoute = require("./routes/profile");
app.use("/profile", profileRoute);
const blogRoute = require("./routes/blogpost");
app.use("/blogPost", blogRoute);
data = {
msg: "Welcome on DevStack Blog App development YouTube video series",
info: "This is a root endpoint",
Working: "Documentations of other endpoints will be release soon :)",
request:
"Hey if you did'nt subscribed my YouTube channle please subscribe it",
};
app.route("/").get((req, res) => res.json(data));
app.listen(port, "0.0.0.0", () =>
console.log(`welcome your listinnig at port ${port}`)
);