-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
29 lines (27 loc) · 880 Bytes
/
app.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
const express = require("express");
const app = express();
const connectDB = require("./db/connect");
require("dotenv").config();
const morgan = require("morgan");
const tasks = require("./routes/tasks");
const notFound = require("./middleware/not-found");
//middleware...
app.use(express.static("./public"));
app.use(express.json()); //this express.json is middleware as it stands b/w request and response ..//data from the body is added to the req
app.use("/api/v1/tasks", tasks);
//404--notFound
app.use(notFound);
//crud-operations routes
const port = 3000;
const start = async () => {
try {
await connectDB(process.env.MONGO_URI);
console.log("😍 DB SUCCESSFULLY CONNECTED\n----------------------------");
app.listen(port, () => {
console.log(`🤩 App is running on port ${port}`);
});
} catch (error) {
console.log(error);
}
};
start();