-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
23 lines (16 loc) · 684 Bytes
/
Copy pathapp.js
File metadata and controls
23 lines (16 loc) · 684 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
require("dotenv").config();
const express = require('express');
const bodyParser = require('body-parser');
const mongoose = require('mongoose');
const tasksRouter = require('./routes/taskRoute');
const middleware = require('./middleware/tasks');
const app = express();
const PORT = process.env.PORT ||3008;
app.use(bodyParser.json());
mongoose.connect(process.env.MONGO_URL).then(() => {console.log('Mongodb is connected Successfully')})
.catch((error) => {console.log(`Error in connecting MongoDb - ${error?.message || error}`)})
app.use( "/api",tasksRouter);
app.use(middleware);
app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`);
});