-
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.
Merge pull request #18 from PerfectFit-project/354-disconnect-user
new endpoint for disconnecting user
- Loading branch information
Showing
4 changed files
with
96 additions
and
3 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,13 @@ | ||
const utils = require('../utils/writer.jsx'); | ||
const RemoveContact = require('../service/RemoveContactService'); | ||
|
||
// eslint-disable-next-line no-unused-vars | ||
module.exports.removeContact = function removeContact(req, res, next, body) { | ||
RemoveContact.removeContact(req, body) | ||
.then((response) => { | ||
utils.writeJson(res, response); | ||
}) | ||
.catch((response) => { | ||
utils.writeJson(res, utils.respondWithCode(500, response)); | ||
}); | ||
}; |
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,30 @@ | ||
const { Contacts, SenseServer } = require('@sense-os/goalie-js'); | ||
require('isomorphic-fetch'); | ||
|
||
const { ENVIRONMENT } = process.env; | ||
let selectedServer; | ||
|
||
if (ENVIRONMENT === 'dev') { | ||
selectedServer = SenseServer.Alpha; | ||
} else { | ||
selectedServer = SenseServer.Production; | ||
} | ||
|
||
const contacts = new Contacts(selectedServer); | ||
|
||
/** | ||
* Get the pending connection requests. | ||
* Returns the JSON as received from the SenseServer. | ||
* @param req - The node.js express request object | ||
* @param body - The node.js express body object. | ||
* */ | ||
exports.removeContact = (req, body) => new Promise((resolve, reject) => { | ||
console.log(req.app.get('token'), req.app.get('therapistId'), body.user_id); | ||
contacts.removeContactFromUserContact(req.app.get('token'), req.app.get('therapistId'), body.user_id) | ||
.then((result) => { | ||
resolve(result); | ||
}) | ||
.catch((error) => { | ||
reject(Error(`Error during contact temoval: ${error}`)); | ||
}); | ||
}); |