Skip to content

Commit

Permalink
intergrate delete query into profile.delete handler
Browse files Browse the repository at this point in the history
relates #116
  • Loading branch information
LawEKS committed May 17, 2018
1 parent dc34d63 commit 42401ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/controllers/profile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const { addUserStatus } = require('./middleware');
const { saveProfileData, saveJobDetails, getMemberData } = require('../model/queries/');
const {
saveProfileData, saveJobDetails, getMemberData, deleteMemberFromDB,
} = require('../model/queries/');

exports.get = (req, res) => {
// this checks if the :github_id in req.params matches (and it's your profile)
Expand Down Expand Up @@ -36,7 +38,11 @@ exports.postJobDetails = (req, res, next) => {

exports.delete = (req, res, next) => {
const { github_id } = req.user;
console.log('delete');
console.log('github id: ', github_id);
res.status(200);
deleteMemberFromDB(github_id)
.then(() => {
res.status(200);
})
.catch((err) => {
next(err);
});
};
2 changes: 1 addition & 1 deletion src/test/db.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ const getMemberIdFromMembers = githubId => dbConnection.query(
).then(res => res[0].id);

test('Test deleteMemberFromDB', (t) => {
const githubId = 1;
const githubId = 3;
let memberId;
runDbBuild()
.then(() => getMemberIdFromMembers(githubId))
Expand Down

0 comments on commit 42401ef

Please sign in to comment.