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:
22
seasoned_api/src/webserver/controllers/user/history.js
Normal file
22
seasoned_api/src/webserver/controllers/user/history.js
Normal 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;
|
||||
Reference in New Issue
Block a user