-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add route and first controller function
- Loading branch information
Showing
4 changed files
with
21 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const mongoose = require('mongoose'); | ||
|
||
const getAllTasks = (req, res, next) => { | ||
res.send('all tasks'); | ||
}; | ||
|
||
module.exports = { | ||
getAllTasks | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ const mongoose = require('mongoose'); | |
|
||
const connectionString = 'mongodb+srv://djibba:[email protected]/taskDatabase?retryWrites=true&w=majority'; | ||
|
||
mongoose.connect(connectionString) | ||
mongoose.connect(connectionString, { useNewUrlParser: true, useUnifiedTopology: true }) | ||
.then(() => console.log('Connection for database successfully !')) | ||
.catch((err) => console.log(err)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const express = require('express'); | ||
const router = express.Router(); | ||
const { | ||
getAllTasks | ||
} = require('../controllers/taskController'); | ||
|
||
router.route('/api/tasks').get(getAllTasks); | ||
|
||
module.exports = router; |