-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 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
31
32
33
34
import express from "express";
import * as dotenv from "dotenv";
import cors from "cors";
import connectDB from "./mongodb/connect.js";
import userRouter from "./routes/user.routes.js";
import propertyRouter from "./routes/property.routes.js";
dotenv.config();
const app = express();
app.use(cors());
app.use(express.json({ limit: "50mb" }));
app.get("/", (req, res) => {
res.send({ message: "Hello World!" });
});
app.use("/api/v1/users", userRouter);
app.use("/api/v1/properties", propertyRouter);
const startServer = async () => {
try {
connectDB(process.env.MONGODB_URL);
app.listen(8080, () =>
console.log("Server started on port http://localhost:8080"),
);
} catch (error) {
console.log(error);
}
};
startServer();