Created endpoints for user tasks like login, register and a test endpoint history. A test for checking that session token works as expected.

This commit is contained in:
2017-09-27 16:19:02 +02:00
parent 6ec6c7f9cb
commit 698d2d6072
3 changed files with 74 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
const SearchHistory = require('src/searchHistory/searchHistory');
const searchHistory = new SearchHistory();
/**
* Controller: Retrieves search history of a logged in user
* @param {Request} req http request variable
* @param {Response} res
* @returns {Callback}
*/
function historyController(req, res) {
const user = req.loggedInUser;
searchHistory.read(user)
.then((searchQueries) => {
res.send({ success: true, searchQueries });
})
.catch((error) => {
res.status(401).send({ success: false, error: error.message });
});
}
module.exports = historyController;