Skip to content

Commit

Permalink
add dotenv package and updating somes files
Browse files Browse the repository at this point in the history
  • Loading branch information
Djibba committed Apr 6, 2022
1 parent 1112ba4 commit 25b3bae
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
21 changes: 20 additions & 1 deletion controllers/taskController.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ const getAllTasks = (req, res, next) => {
res.send('all tasks');
};

const createTasks = (req, res, next) => {

};

const getSingleTask = (req, res, next) => {

};

const updateTask = (req, res, next) => {

};

const deleteTask = (req, res, next) => {

};
module.exports = {
getAllTasks
getAllTasks,
createTasks,
getSingleTask,
updateTask,
deleteTask
};
4 changes: 2 additions & 2 deletions db/connect.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require('dotenv').config();
const mongoose = require('mongoose');

const connectionString = 'mongodb+srv://djibba:[email protected]/taskDatabase?retryWrites=true&w=majority';
const connectionString = "mongodb+srv://" + process.env.DB_USER + ":" + process.env.DB_PASSWORD + "@"+ process.env.DB_HOST +"/" + process.env.DB + "?retryWrites=true&w=majority";

mongoose.connect(connectionString, { useNewUrlParser: true, useUnifiedTopology: true })
.then(() => console.log('Connection for database successfully !'))
Expand Down
9 changes: 7 additions & 2 deletions routes/taskRoute.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
const express = require('express');
const router = express.Router();
const {
getAllTasks
getAllTasks,
createTasks,
getSingleTask,
updateTask,
deleteTask
} = require('../controllers/taskController');

router.route('/api/tasks').get(getAllTasks);
router.route('/api/tasks').get(getAllTasks).post(createTasks);
router.route('/api/task/:id').get(getSingleTask).put(updateTask).delete(deleteTask);

module.exports = router;
1 change: 1 addition & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require('dotenv').config();
const http = require('http');
const app = require('./app');

Expand Down

0 comments on commit 25b3bae

Please sign in to comment.