-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
45 lines (26 loc) · 687 Bytes
/
Copy pathserver.js
File metadata and controls
45 lines (26 loc) · 687 Bytes
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
43
44
45
const express = require("express");
const dotenv = require("dotenv");
const connectDB = require("./db/connect");
const todo = require("./routes/router");
const cors = require("cors");
const app = express();
dotenv.config();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cors());
app.get("/", (req, res) => {
res.send("Todo api");
});
app.use("/todo", todo);
const PORT = process.env.PORT || 5000;
const start = async () => {
try {
await connectDB(process.env.MONGO_URI);
app.listen(PORT, () => {
console.log(`server is running on port ${PORT}`);
});
} catch (error) {
console.log(error);
}
};
start();