-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
34 lines (29 loc) · 975 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
30
31
32
33
34
const express = require("express");
const app = express();
const connectDB = require("./db/conn");
const tasks = require("./routes/tasks.js");
// console.log("Hello");
require("dotenv").config();
// middleware
app.use(express.static('./public'))
app.use(express.json());
app.use('/api/v1/tasks', tasks);
const port = process.env.PORT || 3000;
// Setting up Database and Server to run in async
const start = async () => {
try {
await connectDB(process.env.MONGO_URI);
console.log("Connection to DB successful")
app.listen(port, () => {
console.log(`Server running at port ${port}`)
})
} catch (error) {
console.log(error);
}
}
start();
// app.get('/api/v1/tasks') -get all the tasks
// app.post('/api/v1/tasks') -create a new task
// app.get('/api/v1/tasks/:id') -get task by id
// app.patch('/api/v1/tasks/:id') -update task by id
// app.delete('/api/v1/tasks/:id') -delele task by id