-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (33 loc) · 1017 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
37
38
39
40
41
import express from "express";
import bodyparser from "body-parser";
import mongoose from "mongoose";
import cors from "cors";
import dotenv from "dotenv";
// all routes there
import PostRoutes from "./routes/post.js";
import userRouters from "./routes/users.js";
const app = express();
dotenv.config();
app.use(bodyparser.json({ limit: "30mb", extended: true }));
app.use(bodyparser.urlencoded({ limit: "30mb", extended: true }));
app.use(cors());
app.use("/posts", PostRoutes);
app.use("/user", userRouters);
app.get("/", (req, res) => {
res.send("Full-Stack MERN Projects");
});
const PORT = process.env.PORT || 5000;
mongoose
.connect(process.env.CONNECTION_URL, {
useNewURLParser: true,
useUnifiedTopology: true,
})
.then(() =>
app.listen(PORT, () => {
console.log("connection successfully");
console.log(`server running on port ${PORT}`);
})
)
.catch((err) => console.log(err));
// mongoose.set("strictQuery", false);
// mongoose.set("useFindAndModify", false);