Skip to content

Commit

Permalink
Merge pull request #49 from jennydo/router-pairing-model
Browse files Browse the repository at this point in the history
Added router for pairings-model
  • Loading branch information
jennydo authored Jun 29, 2024
2 parents a2e6a14 + a8c3867 commit 4abe6dd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
24 changes: 20 additions & 4 deletions controllers/match-user-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,26 @@ const getMatchUser = async (req, res) => {
// @route GET /matchUsers/getMatch
// @description: Construct matches for users
// @access: Private
const matching = async (req, res) => {
///// Later call K-clusters from Flask services
const fetchMatchPairs = async (req, res) => {
try {
const response = await fetch('http://localhost:5002/matchPairs', {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
});

if (!response.ok) {
throw new Error(`Error: ${response.status}`);
}

const pairingData = await response.json();
return res.status(200).json(pairingData);
} catch (error) {
console.error('Error fetching match pairs:', error);
return res.status(500).json({ error: 'Internal Server Error' });
}

return res.status(201).json("Chat Matching Algo");
};

// @route POST /matchUsers
Expand Down Expand Up @@ -204,5 +220,5 @@ module.exports = {
deleteMatchUser,
updateMatchUser,
deleteAllMatchUsers,
matching,
fetchMatchPairs,
};
4 changes: 2 additions & 2 deletions routes/match-user-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ const {
updateMatchUser,
deleteMatchUser,
deleteAllMatchUsers,
matching,
fetchMatchPairs,
} = require("../controllers/match-user-controller");

matchUserRouter.use(requireAuth);
matchUserRouter.get("/", getMatchUsers);
matchUserRouter.get('/matching', matching)
matchUserRouter.get('/matching', fetchMatchPairs);
matchUserRouter.get("/:userId", getMatchUser);
matchUserRouter.post("/", createMatchUser);
matchUserRouter.patch("/:userId", updateMatchUser);
Expand Down

0 comments on commit 4abe6dd

Please sign in to comment.